This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
What is the use of having timeout argument for the wait() method? If i understand correctly, both when the (1)thread is notifiied and when the (2)time in the wait method expires, the thread goes to Blocked-for-lock acquisition state.And when the lock on the object is released it goes to ready-to-run state and then to running state whenever it gets chance.
So the call to wait() method returns at the same time in both cases.
And also when the thread is interrupted, does the thread go to Blocked-for-lock acquisition state-->>Ready State-->>Running annd then throws the InterruptedException.Please correct me if i am wrong.
If you specify wait time in milli seconds then the thread will stop waiting after that time. You could say wait(1000) and make the thread to wait for 1 second and then continue execution or if the thread is notified or interrupted before 1second execution of the rest of the program will continue