Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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
 
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic