in the book :
Given:
1. public class WaitTest {
2. public static void main(
String [] args) {
3. System.out.print("1 ");
4. synchronized(args){
5. System.out.print("2 ");
6. try {
7. args.wait();
8. }
9. catch(InterruptedException e){}
10. }
11. System.out.print("3 ");
12. }
13. }
What is the result of trying to compile and run this program?
D is correct. 1 and 2 will be printed, but there will be no return from the wait call because no other
thread will notify the main thread, so 3 will never be printed. It's frozen at line 7.
it works as stated. Prints 1,2 and stops forever.... (because nobody notified it!)
now,, i tried replacing wait() with wait(1000)....
this prints 1 2 (pause) 3....
Does this mean that the overloaded wait with one argument goes directly to runnable state after waiting for 1000 millisecs?
Does it not wait for someone to notify(), after the specified arg time is over?
Thanks in advance.