41. For what reasons might a thread stop execution? a) A thread with higher priority began execution. b) The thread's wait() method was invoked. c) The thread invoked its yield() method. d) The thread's pause() method was invoked. e) The thread's sleep() method was invoked. my answer is b,c,d,e. I don't know what the correct answer is but it tells me I was wrong. could anyone help tell me what is correct and explain? thanks a bunch. chun
bill bozeman
Ranch Hand
Joined: Jun 30, 2000
Posts: 1070
posted
0
The key here is that it says "MIGHT" stop a thread. A. True Some systems will stop threads of lower priority to start threads of higher priority, some don't but again, this might be true. B. True wait() will put the thread into waiting state, so it does stop it. C. True yield() will cause a thread to stop for higher priority threads. So it does cause it to stop. D. False There is no pause method. E. True sleep() will cause a thread to stop for a given amount of time. Bill
deepak1
Greenhorn
Joined: Feb 02, 2001
Posts: 4
posted
0
Hi I am not satisfied with the second option . "The thread's wait() method was invoked." since wait() method is defined in the object class.So how can a thread's wait() method can be invoked. What i meant that the statement should be like that .. "The wait() method is called." thanks deepak
Haining Mu
Ranch Hand
Joined: Jun 01, 2001
Posts: 51
posted
0
I am not satisfied with the second option . "The thread's wait() method was invoked." since wait() method is defined in the object class.So how can a thread's wait() method can be invoked. What i meant that the statement should be like that .. "The wait() method is called."
Thread class inherit wait() from Object, so I think it is now his method. And I think answer e) is wrong since no sleep() method in Thread class which does not take a parameter.
Jyotsna Umesh
Ranch Hand
Joined: May 09, 2001
Posts: 94
posted
0
Originally posted by Haining Mu: Thread class inherit wait() from Object, so I think it is now his method. And I think answer e) is wrong since no sleep() method in Thread class which does not take a parameter.
Hi everybody, I agree with Bill, he has explained well and i see option e is right becoz for exam's purpose you will have to make certain assumptions. Right! Jyotsna
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.