This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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 ]