• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

notify() method doubt

 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


notify() method does not release an object's lock. [TRUE]




Please tell how is this true.

Source: "K&B Bonus Exam"

Thanks,
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dunno how to prove it via a program but hope this quote from K&B should be good enough.


When the wait() method is invoked on an object, the thread executing
that code gives up its lock on the object immediately. However, when notify() is called,
that doesn�t mean the thread gives up its lock at that moment. If the thread is still
completing synchronized code, the lock is not released until the thread moves out of
synchronized code. So just because notify() is called doesn�t mean the lock becomes
available at that moment.


Ch 9 Pg 724.

Also read this post completely (guess it was posted by you).
https://coderanch.com/t/262639/java-programmer-SCJP/certification/Thread-sleep-does-not-release
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Reminder indeed!


Thanks Swarna,
[ May 02, 2007: Message edited by: Chandra Bhatt ]
 
Are we home yet? Wait, did we forget the tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic