aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about wait() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "about wait() method " Watch "about wait() method " New topic
Author

about wait() method

Rashmi Tambe
Ranch Hand

Joined: Aug 07, 2001
Posts: 418
JQ+Question ID :954959231469
Which of the following correctly tells about the effect of calling wait() method on an object?
(Assume that the calling Thread has the lock of that object.)
1. The thread that has called wait stops executing until somebody else notifies it.
2. the object issuing a call to wait() halts until another object sends notify() or notifyall().
Correct answer is 1. I feel, even 2 is correct as the meaning of the statement is same as first. Or else i am interpreting in a different way??? pl, explain the second option.
TIA
Rashmi
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1865
hi Rashmi,
if i'd have been there i 'd go with 1 as in second it says,
"object that issues wait()...". this part is not clear with me as i interpret this as "object having a call to wait()...". now, in that case object having a call to wait() doesn't get blocked. the thread calling that method of that shared object gets locked or goes to waiting state...
second reason for 2nd statement being false is,
"another" object can't notify in anyway the object having wait(). ONLY THE OBJECT THAT IS LOCKED CAN SEND notify TO WAITING THREADS...
i guess my second reasoning is much logical/valid than the first one.
regards
maulin.


1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
Rashmi Tambe
Ranch Hand

Joined: Aug 07, 2001
Posts: 418
Thanx a lot Maulin for the nice reasoning
i found that some of the questions in JQ+ are poorly worded. So its really hard to interprete the meaning out of them. Even if u r clear with the concept , these type of wording can confuse u.
Anyway, thanx
Rashmi
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: about wait() method
 
Similar Threads
JQplus question
about wait() method
MG2 #42
Almost ready to hand up: Just cleaning up and have a few questions
JQ+->Threads-->waitForAll()