InterviewSolution
| 1. |
Why Thread Communication Methods Wait(), Notify() And Notifyall() Are In Object Class? |
|
Answer» In JAVA, wait and notify methods acts as synchronization utility and are essential methods for inter thread communication. HENCE these methods are defined in Object class so that EVERY object will have access to it. Also every Object has a monitor and Locks are made available on PER Object basis. This is ANOTHER reason why wait and notify is declared in Object class rather then Thread class. In Java, wait and notify methods acts as synchronization utility and are essential methods for inter thread communication. Hence these methods are defined in Object class so that every object will have access to it. Also every Object has a monitor and Locks are made available on per Object basis. This is another reason why wait and notify is declared in Object class rather then Thread class. |
|