This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes dan exam doubt 20 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "dan exam doubt 20" Watch "dan exam doubt 20" New topic
Author

dan exam doubt 20

amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
hi in one of dan threads question

i don't understand the question at all....plss tell me what it exactly asking ?

======================
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


the anser are a,b,d,f

in details... i don't understand the language of question


Thanks and Regards, Amit Taneja
Animesh Shrivastava
Ranch Hand

Joined: Jul 19, 2004
Posts: 298

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?

The Question says:
When ur thread , t1 , is running and suppose it invoikes wait on an object obj1, then which of the following occurs?

Like in the code below the anonymous thread being created invokes wait on StringBuffer s1.

Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Hi, I'll give it my best shot..


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?


re-worded:
When the tread 'T1' calls the 'wait' method on the object 'obj1', what will bring back the thread from the wait queue ?

Meaning, when in the thread T1 you do obj1.wait, the object obj1 is unlocked and the thread goes in a "wait" queue.
If you want to the thread to continue its execution, you need to notify him.

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


A) and B) are correct, if you do a notify, the thread will live again. Note that for answer A, if you remove "...and T1 is selected to move out of the wait set" it is wrong. If you don't do a notifyAll(), but rather notify(), only 1 thread from the wait queue is notified and it might not be the one you think.

D) is good because it will interrupt the thread and cause an interruptedException, so the thread will be running again, but in its catch Exception block.

F) is good because if you specify a timeout, the thread will leave the wait queue after the timeout has expired if no one nofified him before.

bye
Alex
[ May 02, 2005: Message edited by: Alex Turcot ]
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
Thanx a ton Alex...
i got ur point v.well..

:-)
just a thing i wanted to clear is that when the thread is interupted and is even caught .. will it be alive if its interupted and caught ?

thanx
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: dan exam doubt 20
 
Similar Threads
Question on a Mock Exam Question
Dan's Question : Thread
Thread from chishlom's mock
Threads in the Dan's exam
Another Thread Q from Dans study guide