If I understood properly what the question was, I think the answer to it is:
you are putting the thread into the waiting state in call method, so as soon as the current thread goes into the waiting state it releases the lock and hence other threads can acquire the lock and continue.
now, I have a doubt.
does the program get lock on String object 'x' or B.class?
in response to your questions:
1) What is the neediness for the import java.util.*; statements?
2) Why is this program doesn't terminate normally?
1) The import of java.util.*; if not needed, the compiler will remove at compile time.
2) My believe is that the program does not terminate normally, because the application has 4 "user" threads that are still "waiting" for a notify event to be called.
Causes current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0). ...
Yes nehaa you are right
the program will not terminate normally because all the threads are waiting on the "x" object and also there is no notify method so all the threads will continue to wait and the program wont terminate normally,But if the overloaded version of wait is used than program may complete normally.
SCJP 1.6 98%
I will open the floodgates of his own worst nightmare! All in a tiny ad: