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
Joined: Aug 05, 2002
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 ]
Joined: Aug 10, 2002
at line 1,if thread can't get the lock of monitor,it is blocked,and at line 3,it blocked.
Joined: Jul 03, 2001
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 ]