You are on page 1of 1

Why wait(), notify() and notifyAll() methods are not in Thread Class ?

Hi Abhinav, Reason z Threads can use Objects to transmit messages from one thread to another, and the se methods allow that to happen. A Thread calls wait() to say "I am waiting for a message to be sent to this obje ct." Another thread can call notify() to say "I am sending a message to that obj ect." The Object is therefore a conduit through which threads communicate withou t explicitly referencing each other. If the methods were in the Thread class, then two threads would need to have ref erences to one another to communicate. Instead, all communicating threads just n eed to agree to use some specific shared resource. __________________

You might also like