How two different class threads communicate with each
other?. send example code.

Answer Posted / puneet khanna

The threads in java follow Mutual exclusion( synchronized)
and co-operation;

for co-operation they need to talk to each other by messages
saying " i am waiting in the wait q anyone can acquire the
lock of the object" or" i have acquired the lock now by
notify() to the last thread who called wait() or by
notifyall() to all the threads who are in the wait q"

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain OOPs concept.

641


Why should we use singleton pattern instead of static class?

454


what is interface in java? Explain

526


What does file separator do in java?

532


Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?

546






What is the difference between length and size in java?

489


Explain the difference between intermediate and terminal operations in java8?

562


Is there any difference between synchronized methods and synchronized statements?

572


What is the use of generics? When was it added to the Java development Kit?

551


What is string :: npos?

573


In how many ways we can do exception handling in java?

569


What is nan inf?

501


Whats the difference between notify() and notifyall()?

564


State one difference between a template class and class template.

614


What is connection class in java?

504