• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Thread qustion

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
The obvious ans. to the code is 2 but I fail to understand why option 4 is wrong?
What is the effect of issuing a wait() method on an object
1. If a notify() method has already been sent to that object then it has no effect
2. The object issuing the call to wait() will halt until another object sends a notify() or notifyAll() method
3. An exception will be raised
4. The object issuing the call to wait() will be automatically synchronized with any other objects using the receiving object.
Thanks
Jyotsna

 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jyotsna
I think 4 is just worded so that it sounds like a good answer. wait() realy doesn't have anthig to do wiht synchronized objects specifically (you can call wait on any thread, regarless of wehter or not its in synchronized code). It's just that usually wait is used within the synchronized code to control access. when you call wait on a thread it just stops and waits. It doesn't do anything else. If it was in synchronozed code it'll release the lock on the monitor but it doesn't do anything to or with any other objects.
Dave
If I'm wrong on anything here someone please corect me.
 
Jyotsna Umesh
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dave Vick:
Jyotsna
I think 4 is just worded so that it sounds like a good answer. wait() realy doesn't have anthig to do wiht synchronized objects specifically (you can call wait on any thread, regarless of wehter or not its in synchronized code). It's just that usually wait is used within the synchronized code to control access. when you call wait on a thread it just stops and waits. It doesn't do anything else. If it was in synchronozed code it'll release the lock on the monitor but it doesn't do anything to or with any other objects.
Dave
If I'm wrong on anything here someone please corect me.


Thanks Dave, maybe the option sounded like a good ans. to me, so got confused.
Jyotsna
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic