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.
开发者_如何学JAVAThanks 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
精彩评论