Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added API quote for await() method - exec in loop

...

Because of these reasons, it is indispensable to check the condition using a loop, after wait() is called.

Wiki Markup
Similarly, the {{await()}} method of interface condition must also be invoked inside a loop. According to the Java API \[[API 06|AA. Java References#API 06]\], Interface {{Condition}}:

When waiting upon a Condition, a "spurious wakeup" is permitted to occur, in general, as a concession to the underlying platform semantics. This has little practical impact on most application programs as a Condition should always be waited upon in a loop, testing the state predicate that is being waited for. An implementation is free to remove the possibility of spurious wakeups but it is recommended that applications programmers always assume that they can occur and so always wait in a loop.

Noncompliant Code Example

...