The FilterSpuriousWakeups flag defaults to true and causes the low-level synchronization routine to ignore a spurious return from pthread_cond_timedwait on Posix systems.
The flag is only used in conjunction with the following Java-level APIs:
- Thread.sleep
- Object.wait(int millis) et al.
but even if we disabled the flag, in the Thread.sleep case it would make no difference as higher-level code will still act to filter the spurious wakeup and prevent an early return.
So in summary this flag can be used to change the behaviour of only one of the three core Java blocking primitives (the third being LockSupport.park(long nanos)).
Given that, and the fact it serves no purpose to disable the flag, then flag can simply be removed. But as this is a product flag we will first deprecate it.
This cleanup should have been done a long time ago.
The flag is only used in conjunction with the following Java-level APIs:
- Thread.sleep
- Object.wait(int millis) et al.
but even if we disabled the flag, in the Thread.sleep case it would make no difference as higher-level code will still act to filter the spurious wakeup and prevent an early return.
So in summary this flag can be used to change the behaviour of only one of the three core Java blocking primitives (the third being LockSupport.park(long nanos)).
Given that, and the fact it serves no purpose to disable the flag, then flag can simply be removed. But as this is a product flag we will first deprecate it.
This cleanup should have been done a long time ago.
- csr for
-
JDK-8270876 Deprecate the FilterSpuriousWakeups flag so it can be removed
-
- Closed
-
- relates to
-
JDK-8270929 Obsolete the FilterSpuriousWakeups flag in JDK 19
-
- Resolved
-