notify() wakes a single waiting thread chosen by the runtime
What it finds
notify() wakes one waiting thread, chosen by the runtime. When threads wait for different conditions on the same object, the one woken may not be the one that can proceed, and the others sleep on. notifyAll() wakes them all to check their conditions.
From the rule's source, notify_one.rs.
class Gate { synchronized void open() { notify();tx0 reports: notify() wakes only one of the waiting threads notifyAll(); }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:notify-one" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:notify-one] reason="..."tx0 explain tx0/java:notify-one shows the same in the terminal. Found a false positive? Report it.