My understanding :-
wait() causes InterruptedException when some other Thread's notify() or notifyall() is called.
sleep() causes interrupt to be called on the Thread which causes InterruptedException.
So I think whenever InterruptedException is thrown,Thread is stopped.
What might cause the current thread to stop executing?
A. An InterruptedException is thrown
B. The thread executes a sleep() call
C. The thread constructs a new Thread
D. A thread of higher priority becomes ready (runnable)
E. The thread executes a read() call on an InputStream
I think A,B,D,E are correct.
Can anybody give a confirmation?
Originally posted by maha anna:
3. The 3rd method is wait(..)
This again has to be inside try-catch-Inter...Excep.. block. A thread myT ,which called wait(..) may throw InterruptedException in 3 occations.
(i) When another thread calls myT.interrupt()
(ii) When another thread calls myT.notify()
(iii)When another thread calls myT.notifyAll()
[This message has been edited by maha anna (edited April 27, 2000).]