Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经裸体通知 FindBugs 的警告。以下是我的代码。
synchronized (this) { this.notify(); }
“this”是“公共类控制器扩展线程”。如何修复警告?我对此一无所知。
提前致谢。
裸通知警告意味着使用 notify() 方法意味着有一些其他线程在等待某个可变状态发生变化,并且正在等待被通知。但是您的同步块没有修改任何可变状态,因此您需要通知似乎很奇怪。如果您在同步块之外修改了对象的状态,那么这段代码是否是线程安全的似乎值得怀疑,因为有另一个线程正在读取这些数据