What can cause a thread to stop executing? 1) The program exits via a call to System.exit(0); 2) Another thread is given a higher priority 3) A call to the thread's stop method. 4) A call to the halt method of the Thread class Answers 1,3 ( or 2 ?) Can I answer 2 also ? As it is not true always.
dropinboy
Greenhorn
Joined: Jan 16, 2001
Posts: 8
posted
0
hi there i think if u call the yeild() method on the current lower-priorty(lower cause another thread has been given higher priority), the thread schedular will c there's a higher-priority and will probably execute the higher-priority thread moving the lower-priority thread into ready-to-run state.
Ishaan Mohan
Ranch Hand
Joined: Jan 20, 2001
Posts: 115
posted
0
Drophinboy, but option 2 didn't mentioned call to yield() or result of yeild().
dropinboy
Greenhorn
Joined: Jan 16, 2001
Posts: 8
posted
0
hi Ishaan i don't think the thread scheduler checks for higher-priority threads unless the current thread yields/dies/interuppted, so just increasing another thread's priority won't stop the current thread.
Ishaan Mohan
Ranch Hand
Joined: Jan 20, 2001
Posts: 115
posted
0
Yes thats why I am confused. In mock exam option 2 is given in answer list. lets wait for others views.
dropinboy
Greenhorn
Joined: Jan 16, 2001
Posts: 8
posted
0
hi Ishaan just read in a book i have, the words verbatim "It can get moved out of the CPU by a higher-priority thread that becomes ready to execute" Book Name:Complete Java 2 Certification(Robert,Heller,Ernest)
bill bozeman
Ranch Hand
Joined: Jun 30, 2000
Posts: 1070
posted
0
Answer is 1, 2, and 3. 1 will always stop it from executing 2 can on some machines cause it to stop. Not guaranteed, but question says can cause a thread to stop 3 will stop it from executing 4 there is not halt method Bill
PS dropinboy, I mentioned in another post about your name not meeting our guidelines. I mention it again in case you haven't looked at that other thread again. Please re-register with a more appropriate name. Check out this link for more info, www.javaranch.com/name.jsp
[This message has been edited by bill bozeman (edited February 28, 2001).]
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
dropinbuy,
Please read the JavaRanch policy on user names at http://www.javaranch.com/name.jsp, and re-register using an ID with a complete (and separate) first and last name, each with more than 1 letter. Thanks, Cindy
"JavaRanch, where the deer and the Certified play" - David O'Meara
denish mehta
Ranch Hand
Joined: Dec 21, 2000
Posts: 135
posted
0
Hi i think 2 is correct because even in time slicing the thread will be stopped from execution atleast for a while and in other os it will have to relinquish control any way any comments???
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.