Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

simple question

 
amar verma
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
 
rajan singh
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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 ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Threading Forum because this question is beyond scope of SCJP.
 
Henry Wong
author
Sheriff
Posts: 22542
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!