• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dan exam doubt 20

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic