Explain the purposes of methods wait(), notify(), notifyAll
()?
Answer Posted / sumitpalsingh
The purpose of using the wait(),notify() and notifyAll() methd is used for interThread communication.
for Example :-There is a n situation communication between Producer and Consumer...Producer wll produce an item and go to waiting state by using wait() method.and it will notify to the consumer for to consume an item. After conume an Item Consumer will come into waiting state by using wait() method ..and give the notification to Produer by using notify() method to produce an item.But all these methods are called only in synhronized() method or synchronized block.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Explain the advantages and disadvantages of detached objects.
How substring() method of string class create memory leaks?
What restrictions are placed on the location of a package statement within a source code file?
What classes of exceptions may be caught by a catch clause?
What are the difference between RMI and CORBA?
How a component can be placed on Windows?
Are enterprise beans allowed to use thread.sleep()?
What are the diff types of exception?
Is the ternary operator written x : y ? Z or x ? Y : z ?
int x=5,i=1,y=0; while(i<=5) { y=x++ + ++x; i=i+2; } System.out.println(x); System.out.println(y); System.out.println(i); How to solve this? Please explain!
What are the pros and cons of detached objects?
why static class in java
What is a session? Can you share a session object between different theads?
Can I use javascript to submit a form?
What is prototype?