Search your topic in Java2share
Home > FAQs
eXTReMe Tracker

Multi Threading FAQs

Untitled Document

Q45. Explain wait(), notify(), notifyAll() method uses.
Ans.  Two Threads will communicate with each other by using wait(), notify() or notifyAll() methods.
         These methods are defined in Object class but not in Thread because Threads are calling this method.

Q46. What is the difference between notify() and notifyAll()?
Ans.  To give notification to the single waiting Thread. We use notify() method and to give notification to all waiting thread we use notifyAll() method.

Q47. Once a Thread got the notification then which waiting thread will get chance?
Ans.   It is depends on the Thread Scheduler.

Q48.   How a thread can interrupt another thread?

Ans.  A Thread can interrupt another Thread by using interrupt() method.