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

Buddy system of memory allocation Free memory is used to maintain in linked lists, each of similar sized blocks. Every block is of size 2^k. When some memory is needed by a th

Direct memory access Many computers avoid burdening the main CPU with programmed I/O by offloading sine if this work to a special-purpose processor known as a direct memory add

Problem: a) The CPU can access 2 storage devices directly. What are these 2 storage devices? b) Define 2 key issues involved in memory management. c) How do processes sha

What are the deadlock p revention methodologies? a.       Necessitate that processes request all resources before starting - if cannot be granted don't run. b.      Process

Q. Presume that a scheduling algorithm at the level of short-term CPU scheduling favours those processes that have used the least processor time in the recent past. Why this algori

Is disk scheduling, other than FCFS scheduling, useful in a single-user environment? Explain your answer. In a single-user environment, the I/O queue usually is blank. Requests

What are the allocation methods of a disk space? Methods of allocating disk space which are widely in use are a. Contiguous allocation b. Linked allocation c. Indexed

What is a Real-time system? A Real-time system is used when inflexible time requirements have placed on the operation of processor or the flow of data so it is often used as a