But there is; look for Condition#await(), and signal() and signalAll(), etc.Anil Philip wrote:. . . how come there isn't the equivalent of the above? . . .
Anil Philip wrote:Before the concurrent classes, we had wait, notify, notifyAll and looping and sleeping outside a synchronized block.
I was wondering, with all the (new to me) convenience classes, how come there isn't the equivalent of the above?
Simon Roberts wrote:You should not use wait/notify etc inside loops and sleeps, and you shouldn't use the newer library features that way either
Stephan van Hulst wrote:
That's not exactly true.
You were always supposed to call wait() inside a loop that checks the waiting condition. That's because wait() can unblock spuriously without a notify() being called.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |