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

simple question

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea , why below methods are in Object class whereas we use it most times with Thread class

wait()
notify()
notifyAll()

thanks
Amar
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These methods are invoked on objects so they are member of object. and these methods deal with lock and each object supposed to have lock for synchronization that is why these methods are in Object class. And by making these methods(final methods) as a member of Object,all objects in java can have lock control..

PLEASE LET ME KNOW IF I AM WRONG....
[ June 17, 2005: Message edited by: rajan singh ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Threading Forum because this question is beyond scope of SCJP.
 
author
Posts: 23956
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It was an interesting decision to give every object in Java, notification functionality. In practically every other threading subsystem, a separate condition variable must be created. On one hand, it is elegant. On the other, it can be argued as an overkill.

I have to admit that I didn't care for this idea, when Java first got released. But over the years, you do get use to it. And even grow to depend on it ...

Henry
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:
It was an interesting decision to give every object in Java, notification functionality. In practically every other threading subsystem, a separate condition variable must be created. On one hand, it is elegant. On the other, it can be argued as an overkill.

I have to admit that I didn't care for this idea, when Java first got released. But over the years, you do get use to it. And even grow to depend on it ...

Henry



I agree. I think it influences poor coding though. Just like allowing synchronized methods.

to the OP, I have never called wait() on a Thread object.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic