...
When used securely, the signal() method has better performance than signalAll().
When notify() or signal() is used to waken a waiting thread, and the thread is not prepared to resume execution, it often resumes waiting. Consequently, no thread wakens, which may cause the system to hang.
Noncompliant Code Example (notify())
...
Notifying a single thread rather than all waiting threads can violate the liveness property of the system.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
THI02-J | Low | Unlikely | Medium | P2 | L3 |
Automated Detection
Related Guidelines
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Parasoft Jtest |
| CERT.THI02.ANF | Do not use 'notify()'; use 'notifyAll()' instead so that all waiting threads will be notified | ||||||
| SonarQube |
| S2446 | "notifyAll" should be used |
Related Guidelines
Bibliography
...
...