File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread from chishlom's mock

 
Rishi Wright
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 443
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 133
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i would have gone for a and b and f, anyone knows the right answer ???
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic