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
how to differentiate scheduling algorithms?

idle thread The special thread a dispatcher will run when no ready thread is found. The primary purpose of the idle process and its threads is to remove what would otherwise b

Explain the Advantage of Assembly Language The advantages of assembly language program is: a)    Reduced errors  b)    Faster translation times  c)    Changes could be ma

Suppose a logical address space is 1KB, and the page-size is 16 bytes. Assume no page is in the main memory for this process initially and the pure demand paging is used. Current f

Locality of reference entails that the page reference being made by a process  Locality of reference entails that the page reference being made by a process is similarly to be

Difference between threads and processes 1. Thread is flow of implementation. Process is group of instruction which is alike to that of a program except which may be stopped an

Discuss the concepts of  task decomposition  and  data decomposition  within the context of parallel programming. Parallel programming or parrelel computing is the simultaneo

code for implementing NFU page replacement algorithm


Garbage collectors trade space for time. If we collect all the time (which requires a lot of processing time), the GC allocator will use the least memory possible. On the other han