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

MindQ question #41

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
I answered a,c, and e. The answers given are a,b,c, and e. I don't believe answer b is correct. It's not the "thread's" wait() method that gets called but rather the "thread" calls the wait() method of the monitor. Correct?
Thanks,
Greg
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't thing yield() is the correct answer. It only puts the thread to ready state but not stop it.
 
greg groff
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kirti,
I'm not sure if i totally agree with you. Yes, the Thread does go into the Ready state, but the Thread does stop executing until the scheduler reschedules the Thread to execute again, unless there are no other threads to yield to.
Any responses to answer B???
Thanks,
Greg
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any responses to answer B???
u know, objects imlementing Runnable interface or extending Thread class also extend Object class which is the root for all of classes. Among Object class's methods, wait() is one, so we can say a thread has a wait() method althogh it hierients from Object.
u say wait() is a method of monitor. I doubt it. Speaking in theory, monitor in Java is just a mechanism for programmer and developers and the implement of the mechanism is don by VM. Unlike Java, C++ owns a series of methods to deal with sychronization so called, so you can explicitly call those methods, right? At last, I think wait() is owned by objects not class monitor.
do you think so? Please Let me know if you have more correct reply.
regds
George
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic