java ,wait ,notify notifyall# Java - 爪哇娇娃
i*p
1 楼
I have the same question as this.
--------------------------------------------
I am confused a bit about wait and notify/notifyall.
I know there is a lock for every java object. I know wait will release the
lock for other thread. How about notify/notifyall? Does notify/notifyall
realse the lock it is holding for other thread?
-------------------------------------------------
There are 2 different answers for it on this link
http://stackoverflow.com/questions/5999193/java-wait-notify-not
Could anyone here tell me which one is the right answer?
The result from my test seems that the thread calling "notify" releases the
lock right away. If this is true, the rest of code in the synchronized
method is not under protection by the lock.
--------------------------------------------
I am confused a bit about wait and notify/notifyall.
I know there is a lock for every java object. I know wait will release the
lock for other thread. How about notify/notifyall? Does notify/notifyall
realse the lock it is holding for other thread?
-------------------------------------------------
There are 2 different answers for it on this link
http://stackoverflow.com/questions/5999193/java-wait-notify-not
Could anyone here tell me which one is the right answer?
The result from my test seems that the thread calling "notify" releases the
lock right away. If this is true, the rest of code in the synchronized
method is not under protection by the lock.