19 lines
503 B
Plaintext
19 lines
503 B
Plaintext
The point of calling ``++notify++``, or more prefereably ``++notifyAll++``, is to alert other threads that the state of ``++this++`` object has changed. Doing so without a state change seems pointless, and may indicate a logic error.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,text]
|
|
----
|
|
public void run(){
|
|
synchronized(this){
|
|
int total = 0;
|
|
for(int i=0; i<100 ; i++){
|
|
total += i;
|
|
}
|
|
notify(); // Noncompliant; only local variables have been modified. What's the point?
|
|
}
|
|
}
|
|
----
|
|
|