简体   繁体   English

如何修复FindBugs的Naked通知警告?

[英]How to fix Naked notify warning of FindBugs?

I have Naked notify warning of FindBugs. 我有FindBugs的Naked通知警告。 The below is my code. 以下是我的代码。

synchronized (this) {
        this.notify();
    }

The "this" is "public class Controller extends Thread". “this”是“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. 裸通知警告意味着使用notify()方法意味着有一些其他线程正在等待某个可变状态发生更改,并且正在等待通知。 But your synchronized block did not modify any mutable state, and so it seems odd that you would need the notify. 但是你的synchronized块没有修改任何可变状态,所以你需要通知它似乎很奇怪。 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 如果你修改了同步块之外的对象的状态,那么这个代码是线程安全的似乎是可疑的,因为有另一个线程正在读取这些数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复“潜在路径遍历(文件读取)”的Findbugs安全警告 - How to fix Findbugs security warning for 'Potential Path Traversal (File Read)' 如何修复 FindBugs 的警告“使用非本地化 String.toUpperCase() 或 String.toLowerCase()”? - How to fix FindBugs' warning "Use of non-localized String.toUpperCase() or String.toLowerCase()"? ThreadLocal初始化上的FindBugs警告 - FindBugs warning on ThreadLocal init 如何正确使用@SuppressFBWarnings忽略printStackTrace findbugs警告 - How to use @SuppressFBWarnings correctly to ignore printStackTrace findbugs warning 如何摆脱Mockito模拟未初始化的读取findbugs警告 - How to get rid of Mockito mock Uninitialized read findbugs warning 如何解决FindBugs警告“从非常数字符串生成预准备语句”? - How to resolve FindBugs Warning “A prepared statement is generated from a nonconstant String”? 如何修复直接写入HTTP头输出的Findbugs HTTP参数 - How to fix Findbugs HTTP parameter directly written to HTTP header output 修复此“从实例方法写入静态字段”findbugs 警告的最佳方法是什么? - What's the best way to fix this 'write to static field from instance method' findbugs warning? 逐步抑制findbugs警告 - Suppressing findbugs warning Step by Step 有没有办法忽略单个 FindBugs 警告? - Is there a way to ignore a single FindBugs warning?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM