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 a file? A named collection of related data explained by the creator, recorded on secondary storage.

To explore the UNIX file system, use basic UNIX commands and use a text editor. Task:   1.      Logon to Linux. 2.      Create a directory "Unix" under your home d

breifly write a note on about evolution of operating system?

What is critical section? Every process has a segment code called the critical section, in which the process may be updating tables, changing variables, writing file and etc. W

What are the benefits of thread pools:- The benefits of thread pools are 1. It is usually faster to service a request with an existing thread than waiting to make a thread.

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

Determining the time quantum for a job is a critical task. Given the assumptions that the average switching time between processes is s, and the average amount of time an I/O bo

Q.  What kind of operating system is Windows XP? Describe two of its major features. Answer: A 32 or 64 bit pre-emptive multitasking operating system supporting multiple use

Define deadlock avoidance. An alternative method for avoiding deadlocks is to need additional information about how resources are to be requested. Every request requires the sy

What is a reference string? An algorithm is evaluated by running it on a particular string of memory references and computing the number of page faults. The string of memory re