• 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
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

How to use wait(), notify() methods in static synchronized methods.

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Some one can explain me, how to call wait(), notify() methods from static synchronized methods, with some practicle example.
Or direct me, where i can the examples on the net.
Thanks in Advance.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can use a third party object's lock in a synchronized block to do that.
All this in a static method:


obj is the third party object.
Hope that helps,
Sindhur.
 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sindhur,

Thanks for reply.
Here my request is, how to use wait() and notify() methods in static synchronized methods. Not in blocks.
I hope you got my point.
Thanks..
 
Sindhur Sat
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Narasimha,
You cannot call wait() and notify() from a static context without a third party object.
Reason:
no object lock to wait on.
Remember wait and notify are not static methods they cannot be called from a static context unless you call it with an object instance, in which case you have to own its lock in the first place, hence the synchronized block.
K&B explain it very well.
Sindhur.
[ March 06, 2004: Message edited by: Sindhur Sat ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic