I would appreciate your help in understanding the "Concurrency Example" from:
http://forums.sun.com/thread.jspa?threadID=735386
Qute start:
public synchronized void enqueue(T obj) {
this.notify();
}
public synchronized T dequeue() {
while (this.size()==0) {
this.wait();
}
return
}
End quote:
My question is: Why is this code valid?
=> When I synchronize a method like " public synchronized" =>, I synchronize in "Object Instance ==> this". However, in the above example:
Call "dequeue" I will get a "lock / monitor" on this
Now I am in the dequeue method. Since the list is zero, the calling thread will be " waited"
- , , - ( ), "dequeue" , "dequeue"
this: "enequeue", "this".
Backround: : - (List of Connections) , . , ?
Jens