Forums Register Login

wait() or notify()??

+Pie Number of slices to send: Send
either a thread is blocked outside the synchronized code or in I/O,will it realse the lock and be added to the objet's wait pool??
if I never call wait(),need i call notify(),notifyAll().
really confused
+Pie Number of slices to send: Send
Hi Sun:
I can not follow your question. Can you restate it? What do you mean by "blocked"?
Thanks
Barkat
[ September 12, 2002: Message edited by: Barkat Mardhani ]
+Pie Number of slices to send: Send

at line 1,if thread can't get the lock of monitor,it is blocked,and at line 3,it blocked.
+Pie Number of slices to send: Send
Sun when a thread arrives to a region of code protected by an unavaliable monitor, it blocks in the entry set of the monitor(aka mutex). It leaves it when the mutex becomes available and enters the region of the monitor to execute it and to access the shared variables. Being excutin the region of code protected by the monitor if it calls wait on that mutex it will stop execution and it will block being added to the waiting set of the mutex. It will stay there untill other thread will invoke notifyAll() or sometimes notify() on that mutex.
In this online chapter of Inside the Java 2 Virtual Machine by Bill Venners you can read much more.
There is also a picture about a monitor showing the entry and wait sets.
[ September 13, 2002: Message edited by: Jose Botella ]
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 585 times.
Similar Threads
wait and notify
Input without action listeners: JOptionPane?
wait vs. notify
Wait(),notify() and join() mtd
lingering wait()/notify() and deadlock doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:15:51.