Monday, 15 July 2013

multithreading - Are Java wait(), notify() 's implementation significantly different from locks? -


Out of curiosity, when Java is awaiting () and indicates () the way, they are actually just locks Using? That is, wait () a mute x receives, inform () release a mute x, notify all () all the mutes (in the same object, exactly)?

In addition to being less cumbersome than using a lock, what are the other advantages of using and waiting?

[edit] I realized what I got confused about Brian's comments:

does not stop, it releases the lock and sends it to someone else Waiting on the synchronized statement for Mutex, can be notified by another person who has a lock and the call is informed, which passes through the original thread which is said to be the wait . I guess that's where you're confused. Brian 17 minutes ago

wait () and notify () Do not acquire any monitors In the form of a tactic for these methods, the caller must obtain the monitor before calling. In fact, waiting () actually calls the release monitor (though, I think technically wait ) in the end Return).

No comments:

Post a Comment