+ 9

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

27th May 2017, 11:51 AM
Louis - avatar
3 Answers
+ 11
Wait and notify is not just normal methods or synchronization utility, more than that they are communication mechanism between two threads in Java. And Object class is correct place to make them available for every object if this mechanism is not available via any java keyword like synchronized. Remember synchronized and wait notify are two different area and don’t confuse that they are same or related. Synchronized is to provide mutual exclusion and ensuringthread safety of Java class like race condition while wait and notify are communication mechanism between two thread.
28th May 2017, 5:33 AM
+ 10
congratulations Zach for level up ....😀. keep it up ...👍
29th May 2017, 10:38 AM
Louis - avatar
+ 8
28th May 2017, 5:35 AM
Louis - avatar