Why we need to use a while statement when using wait method, Operating System

Q. The wait() statement in every Java program examples was part of a while loop. Describe why you would always need to use a while statement when using wait() and why you would never use an if statement.

Answer: This is a significant issue to emphasize! Java only provides anonymous notification-you can't notify a certain thread that a certain condition is true. When a thread is informed it is its responsibility to re-check the condition that it is waiting for. If a thread didn't recheck the condition it might have received the notification without the condition having been met.

Posted Date: 7/27/2013 3:55:31 AM | Location : United States







Related Discussions:- Why we need to use a while statement when using wait method, Assignment Help, Ask Question on Why we need to use a while statement when using wait method, Get Answer, Expert's Help, Why we need to use a while statement when using wait method Discussions

Write discussion on Why we need to use a while statement when using wait method
Your posts are moderated
Related Questions
What is the use of inter process communication. Inter process communication gives a mechanism to allow the co-operating process to communicate with each other and synchronies t

What is virtual memory? Virtual memory is a method that allows the execution of processes that might not be completely in memory. It is the separation of user logical memory fr

Can a direct access file be read sequentially? Explain. Yes. Keep a counter, cp, initially set to 0. After reading record cp, increment cp.

USER-LEVEL THREADS (ULT) In this level the kernel isn't aware of the existence of threads -- All thread management is complete by the application by using a thread library. Th



Direct communication With direct communication each process that requires to communicate must explicitly name the recipient or sender of the communication. The send and receive

Question : The file system is the most visible aspect of an operating system. It provides the mechanism for on-line storage and access to both data and programs of the operatin

What are the objectives and functions of operating system? Functions of operating systems 1.      It allocates the resources and acts as a supervisor. 2.      It hides th

why we say OS is a resource allocator and control program