• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

dan exam doubt 20

 
Ranch Hand
Posts: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 817
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic