Win a copy of Murach's MySQL this week in the JDBC and Relational Databases 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
  • 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

Question on Wait() method

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came across this question on a mock test
Q. 39. What is the effect of issuing a wait() method on an object
(A)If a notify() method has already been sent to that object then it has no effect
(B)The object issuing the call to wait() will halt until another object sends a notify() or notifyAll() method
(C)An exception will be raised
(D)The object issuing the call to wait() will be automatically synchronized with any other objects using the receiving object.
Select the most appropriate answer.
Answer Given : B.
B says the object issuing the call to wait() will halt....sounded a little ambigous to me at first.
Am I right in assuming what it means is that the thread (that is object) issues the call to wait()...it actually asks itself to wait, and it waits till it gets a notify() or notifyAll()?
Monisha.
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Monisha,
Your assumption is right. The author of this mock exam has not framed the sentance properly, he is used the term 'object', instead of 'thread'.


The object issuing the call to wait() will halt until another object sends a notify() or notifyAll() method


This could be corrected as


Issuing a wait on a object will halt the currently excuting thread untill another thread invokes a notify() or notifyAll() method on the this object.


Hope this helped you
reshma
[ April 07, 2003: Message edited by: Reshma Pai ]
 
Monisha Talwar
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah Reshma, that sounds much better...thanks a ton.
Monisha.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic