0% found this document useful (0 votes)
37 views1 page

Inter Thread Communication

Uploaded by

NAKKA PUNEETH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views1 page

Inter Thread Communication

Uploaded by

NAKKA PUNEETH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Inter-thread Communication

We have few methods through which java threads can communicate with each other. These
methods are wait(), notify(), notifyAll(). All these methods can only be called from within
a synchronized method.

1) To understand synchronization java has a concept of monitor. Monitor can be thought of as


a box which can hold only one thread. Once a thread enters the monitor all the other threads
have to wait until that thread exits the monitor.

2) wait()  tells the calling thread to give up the monitor and go to sleep until some other thread
enters the same monitor and calls notify().

3) notify() wakes up the first thread that called wait() on the same object.


notifyAll() wakes up all the threads that called wait() on the same object. The highest
priority thread will run first.

You might also like