a. Another Thread invokes the notify method on the Object, Obj1, and T1 is selected to move out of the wait set.
b. Another Thread invokes the notifyAll method on the Object.
c. Another Thread invokes the resume method on Thread T1.
d. Another Thread interrupts Thread T1.
e. The priority of Thread T1 is increased.
f. A specified timeout period has elapsed.
g. Another Thread invokes the join method on Thread T1.
h. None of the above.
Answer : a b d f
Can someone explain why b?
(b) Notify All does not garuntee that this waiting thread will not wait any more right...because another thread could me chosen instead of T1. Shouldnt the choice say
"Another Thread invokes the notifyAll method on the Object and T1 is selected to move out of the wait set"?
Some other thread invokes the notify method for that object and thread T happens to be the one arbitrarily chosen as the one to notify.
Some other thread invokes the notifyAll method for that object.
If the call by thread T to the wait method specified a timeout interval, the specified amount of real time has elapsed.
So the answer definately complies with that.
Infact just read another quote from Kathy / Bert which says
In most scenarios, it's preferable to notify all of the threads that are waiting on a particular object. If so you can use notifyAll() on the object to let all the threads rush out of the waiting area and back to runnable.
I guess I carelessly assumed that only 1 thread was picked to go to runnable and then to running state, but indeed, all go into runnable, and then 1 to running state!
Sorry, my bad!!
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Thread Boost - a very different sort of advertisinghttps://coderanch.com/t/674455/Thread-Boost-feature