Thursday, 15 March 2012

java - Is notifyAll() required at the end of a synchronized block? -



java - Is notifyAll() required at the end of a synchronized block? -

i used write synchronized block like:

synchronized(foobar) { // }

but, saw write:

synchronized(foobar) { // foobar.notifyall(); }

is foobar.notifyall(); necessary? happens if omit it?

you don't need this. have if object (here foobar) waiting notified. notify wakes threads waiting on object's monitor.

java

No comments:

Post a Comment