This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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