Explain the purposes of methods wait(), notify(), notifyAll
()?
Answers were Sorted based on User's Feedback
Answer / tek
All the three methods are called in synchronized block or
method.
wait(): Thread calling wait method will go to the waiting
state and it will loose its monitor. It will execute only
if it is notified by the other threads.
notify(): To notify thread which is waiting for the concern
object.
notifyAll(): To notify all the threads which are in waiting
state.
| Is This Answer Correct ? | 2 Yes | 0 No |
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 |
How two threads will communicate with each other?
AS a developer will u create a data source in connection pool? If so how will u do that, how to access the object from connection pool using IRAD tool?
whats is mean by class.forName() whats the return type of class
Is a class a subclass of itself?
Can I import same package/class twice? Will the jvm load the package twice at runtime?
What is the lifecycle of an applet?
Is infobus easy to use?
the same information whether it will connect to the database or it will be used previous information?
What is colon_pkg_prefixes and what is its use?
What are the disadvantages of using threads?
What is the difference between Super and This Keyword?
Which are the different segments of memory?