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
Q. Why is it important to scale up system bus and device speeds as the CPU speed increases? Answer: Consider a system which carries out 50% I/O and 50% computes. Doubling-up

Write a short note about the different STATES of a process. As a process implement it changes state. The state of a process is described in part by the current activity of that

Q. Is the Internet a LAN or else a WAN? Answer: The Internet is a WAN as the a variety of computers are located at geographically different places and are connected by long-dis


The 5Z Company is selling pens to the local market. It is planning to maximize sales and profit by analyzing few conditions using the break-even analysis formula. Below is the data

Explain how protection is provided for the hardware resources by the operating system. Dual mode operation Sharing system resources needs operating system to make sure

Differentiate pre-emptive and non-preemptive scheduling In a pre-emptive scheduling technique, CPU can be taken away from a process if there is a requirement while in a non-pre

Q. What are two differences among user-level threads and kernel-level threads? Under what situations is one type better than the other? Answer: (1) User-level threads are un

Characteristics of suspend process Suspended process isn't immediately available for execution. The process may or may not be waiting on an event. For preventing t

Some people write custom memory allocators to meet their speci?c needs. Although this is not needed for most of the applications, it is also not uncommon. The goal, of course, is t