0

Why wait and notify is declared in Object class instead of Thread?

One Of the Toughest Questions asked in java.

25th May 2017, 7:09 PM
Saurabh Sharma
Saurabh Sharma - avatar
1 Answer
+ 3
As every object in java has only one lock(monitor) and wait (), notify (),notifyAll() are used for monitor sharing thats why they are part of Object class rather than Thread class . These methods works on the locks and locks are associated with Object and not Threads .
25th May 2017, 7:25 PM
Eremie Gillowei
Eremie Gillowei - avatar