aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on Wait() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question on Wait() method" Watch "Question on Wait() method" New topic
Author

Question on Wait() method

Monisha Talwar
Ranch Hand

Joined: Feb 11, 2003
Posts: 102
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.


Hey! It compiles! Ship it!
Reshma Shanbhag
Ranch Hand

Joined: Sep 17, 2002
Posts: 202
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 ]

SCJP 1.4, SCWCD 1.4
Monisha Talwar
Ranch Hand

Joined: Feb 11, 2003
Posts: 102
Yeah Reshma, that sounds much better...thanks a ton.
Monisha.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Wait() method