• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Thread execution

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
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
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
It's never done THAT before. Explain it to me tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic