Post a Job  |   Ask a Question?   |   Already registered? login or register
PraveenKumar B
28/04/2016 12:10 PM

TOP MNC interview questions for 2+

cognizant : wait() notify() notifyAll() are belongs to Thread then why they are placed on Object Class ................. POLARIS: Diff b/w HashMap and ConcurentHashMap ....................... Birlasoft: 1.write Prime number program with minimum iterations. 2.Tell me count of each alphabet in given String using collections. 3. Scenario where to use 11EndPoint and 12EndPoint in SOAP.
Spam    2 Comments

28/04/2016 13:19:16
here wait(),notify(),notifyAll() methods are not belong to Thread class directly ,these methods are provided by Object class only. bcz Object class is a super class for all java class

28/04/2016 14:44:44
wait() notify() notifyAll() methods works on the locks and locks are associated with Object and not Threads.Here one thread should call the another thread to woke up. In Java, the object itself is the entity that is shared between threads which allows them to communicate with each other. The threads have no specific knowledge of each other and they can run asynchronously. They run and they lock, wait, and notify on the object that they want to get access to. They have no knowledge of other threads and don't need to know their status. They don't need to know that it is thread2 which is waiting for the resource -- they just notify on the resource and whomever it is that is waiting (if anyone) will be notified.

Languages :