Author | Topic: Thread execution |
art unregistered |
posted February 23, 2000 11:13 AM
For what reasons might a thread stop execution? a) A thread with higher priority began execution. I think the answer is a,b,e. I am not sure about choice d. Should we take d as right as yield temporarily pauses executing a thread
|
maha anna bartender |
posted February 23, 2000 01:06 PM
a) A thread with higher priority began execution. (YES) b) The thread's wait() method was invoked. (YES) c) The thread invoked its yield() method. (YES) d) The thread's pause() method was invoked.(NO) e) The thread's sleep() method was invoked.(YES) maha anna
|
Anju unregistered |
posted February 23, 2000 01:10 PM
I think "C" must be a valid answer too because the thread which has yielded stops executing and may resume immediatly if there are no other high priority threads waiting or yield if there is a high priority thread. It is just like sleep or wait in that respect. Regarding "Pause" - not sure if there is any such method?
|
Jim Yingst sheriff |
posted February 23, 2000 01:23 PM
I agree with maha anna and Anju's answers (no, there is no pause() method.) However I wanted to note that B is misleading. Very often you don't invoke wait() on the Thread itself, but on some other object which you've been synchronizing on - the monitor. It is possible that the Thread instance is the monitor, so B can be true, but I'd like the question better if it had said "b) An object's wait() method is invoked" instead.
|
| | |