P
pt
hello, all
I am puzzled by monitor.wait() and monitor.pulse().
Currently, my understanding is if a thread calls wait(), it must
be pulsed first before it can wake up. What is the benifit
to realize the syschronization as so? In my inpression, no
other synchronization mechanism like it.why not simply use wait()
and let the wait() can wakeup without being pulsed()? I know the
pulse() introduces more control, but is there some example show the
benefit of pulse() ?
Also, I know the difference of pulse() and pulseall(), but I
think in most case pulseall() is enough I would like to know
in which case pulse() should be used as necessary?
many thanks!
I am puzzled by monitor.wait() and monitor.pulse().
Currently, my understanding is if a thread calls wait(), it must
be pulsed first before it can wake up. What is the benifit
to realize the syschronization as so? In my inpression, no
other synchronization mechanism like it.why not simply use wait()
and let the wait() can wakeup without being pulsed()? I know the
pulse() introduces more control, but is there some example show the
benefit of pulse() ?
Also, I know the difference of pulse() and pulseall(), but I
think in most case pulseall() is enough I would like to know
in which case pulse() should be used as necessary?
many thanks!