This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Threads

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Drophinboy,
but option 2 didn't mentioned call to yield() or result of yeild().
 
dropinboy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes thats why I am confused. In mock exam option 2 is given in answer list.
lets wait for others views.
 
dropinboy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic