I have Naked notify warning of FindBugs. The below is my code.
synchronized (this) {
this.notify();
}
The "this" is "public class Controller extends Thread". How to fix the warning?? I have no idea for it.
Thanks in advance.
The naked notify warning means that using the notify() method implies that there is some other thread waiting for some mutable state to change, and is waiting to be notified. But your synchronized block did not modify any mutable state, and so it seems odd that you would need the notify. If you modified the state of an object outside of the synchronized block, then it seems dubious that this code is thread safe, as there is another thread that is reading this data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With