How two threads will communicate with each other?

Answer Posted / bindhu

Two threads can communicate with each other using
the wait() and notify() , notifyAl() methods. wait()
method tells the thread to wait until another threads
calls notify() method.

The wait() method causes the current thread to wait
(possibly forever) until another thread notifies it of a
condition change. We use wait() in conjunction with notify
() or notifyAll() to coordinate the activities of multiple
threads using the same resources.

The notifyAll() method notifies all the threads waiting on
the monitor held by the current thread and wakes them up.
Typically, one of the waiting threads will grab the monitor
and proceed.

Is This Answer Correct ?    57 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by Socket Programming?

536


how to use debug in my elipse to solve problems that exist in my project

1754


What is the purpose of the notify() method?

587


What are the sequence of steps to write pub or sub model kind of application?

1879


What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

568






Explain how will the struts know which action class to call when you submit a form?

511


Is “abc” a primitive value?

604


What are the difference between RMI and CORBA?

613


What is threadfactory?

602


What is in-memory replication?

547


Name the eight primitive java types.

584


How can I scroll through list of pages like the search results in google?

559


what is an isolation level?

2202


Why do threads block on i/o?

667


Explain about thread synchronization inside a monitor?

1987