-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
15
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Relates to directly to openjdk-15-loom+3-20_windows-x64_bin but indirectly to all previous releases.
A DESCRIPTION OF THE PROBLEM :
Was looking at https://stackoverflow.com/a/12787137 : a proposed use of Phaser for the good old "Ping Pong" example.
Although this example 'works' it ONLY does so because it is relying on an implicit implementation feature: that tasks that have come together at awaitAdvance() are re-scheduled in a fixed, known, repeatable fashion (ie FIFO I believe [as a result of the current implementation being based on ArrayBlockingQueue]).
This is surely an incorrect assumption for the 'ideal' Phaser (& other Synchronizers such as CountDownLatch, etc.).
In any case, it is not stated in any doco.
IMHO, the order that tasks become eligible for re-scheduling should NOT be assumed...one should assume randomness unless one is told otherwise.
The documentation should make the intended behavior clear, and state either:
+ tasks are released to execution in FIFO order
Or:
+ tasks may be resumed with no guarantee as to ordering (i.e.: NOT FIFO or anything else)
In the former case, FIFO behavior is formalized and becomes a known part of the API for these classes. In the latter case randomness is formalized.
*I* believe it is better to assume randomness.
In any case, the definition and doco becomes a bit better.
Note that this is not covered by the statements regarding "Memory Consistency Properties/happens-before"...this is about a re-scheduling decision after memory consistency is taken care of.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See
https://download.java.net/java/early_access/jdk15/docs/api/java.base/java/util/concurrent/Phaser.html
Also "Synchronizers" at:
https://download.java.net/java/early_access/jdk15/docs/api/java.base/java/util/concurrent/package-summary.html
for example.
FREQUENCY : always
Relates to directly to openjdk-15-loom+3-20_windows-x64_bin but indirectly to all previous releases.
A DESCRIPTION OF THE PROBLEM :
Was looking at https://stackoverflow.com/a/12787137 : a proposed use of Phaser for the good old "Ping Pong" example.
Although this example 'works' it ONLY does so because it is relying on an implicit implementation feature: that tasks that have come together at awaitAdvance() are re-scheduled in a fixed, known, repeatable fashion (ie FIFO I believe [as a result of the current implementation being based on ArrayBlockingQueue]).
This is surely an incorrect assumption for the 'ideal' Phaser (& other Synchronizers such as CountDownLatch, etc.).
In any case, it is not stated in any doco.
IMHO, the order that tasks become eligible for re-scheduling should NOT be assumed...one should assume randomness unless one is told otherwise.
The documentation should make the intended behavior clear, and state either:
+ tasks are released to execution in FIFO order
Or:
+ tasks may be resumed with no guarantee as to ordering (i.e.: NOT FIFO or anything else)
In the former case, FIFO behavior is formalized and becomes a known part of the API for these classes. In the latter case randomness is formalized.
*I* believe it is better to assume randomness.
In any case, the definition and doco becomes a bit better.
Note that this is not covered by the statements regarding "Memory Consistency Properties/happens-before"...this is about a re-scheduling decision after memory consistency is taken care of.
REGRESSION : Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See
https://download.java.net/java/early_access/jdk15/docs/api/java.base/java/util/concurrent/Phaser.html
Also "Synchronizers" at:
https://download.java.net/java/early_access/jdk15/docs/api/java.base/java/util/concurrent/package-summary.html
for example.
FREQUENCY : always