wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread from chishlom's mock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread from chishlom Watch "Thread from chishlom New topic
Author

Thread from chishlom's mock

Rishi Wright
Ranch Hand

Joined: Jun 25, 2003
Posts: 46
Hi Ranchers.
here is question from DanChishlom's mock exam..
After invoking the wait method on an Object, Obj1, a Thread, T1, will remain in the wait set of Obj1 until which of the following occurs?
a. Another Thread invokes the notify method on the Object, Obj1, and T1 is selected to move out of the wait set.
b. Another Thread invokes the notifyAll method on the Object.
c. Another Thread invokes the resume method on Thread T1.
d. Another Thread interrupts Thread T1.
e. The priority of Thread T1 is increased.
f. A specified timeout period has elapsed.
g. Another Thread invokes the join method on Thread T1.
h. None of the above.
I think
the option a is not always correct as notify method may call other waiting thread keeping T1 in wait set...
similarly we cannot say f is the right answer because we dont know the syntax of wait...
am I right?
thnx
rishi
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443

the option a is not always correct as notify method may call other waiting thread keeping T1 in wait set...

Yes, you are right that notify() will not guarantee any thread that it will be selected. But in this scenario, answer a is very specific when it says that "T1 is selected to move out of the wait set. "

similarly we cannot say f is the right answer because we dont know the syntax of wait...

Similarly, answer f is also very specific when it says that "A specified timeout period has elapsed". That statement could only mean one thing, that the version of wait() used was the one where you specify an elapse time.
[ August 15, 2003: Message edited by: Alton Hernandez ]
Deep Chand
Ranch Hand

Joined: Dec 17, 2002
Posts: 133
I think a and b are the right answers. b is also the right one bcoz when notifyAll is invoked, all the threads waiting on that object will be notified and come out of the wait state.
am i right?
Thanks,
Deep
Shafkat Talli
Ranch Hand

Joined: Aug 01, 2003
Posts: 30
i would have gone for a and b and f, anyone knows the right answer ???


---------------------------<br />Shafkat Talli<br />SCJP 1.4, August 2003.
 
wood burning stoves
 
subject: Thread from chishlom's mock
 
Similar Threads
Question on a Mock Exam Question
Dan's Question : Thread
Threads in the Dan's exam
Another Thread Q from Dans study guide
dan exam doubt 20