concurrency
concurrency copied to clipboard
TCK enhancement pool for task completion instead of sleeping
Currently, there are a number of tests that will use Thread.sleep()
to pause execution to wait for task completion.
During the TCK port I centralized this activity to a single point for future enhancement:
https://github.com/jakartaee/concurrency/blob/cc64ec4fdac28f24145f8c99b4af55c8e1f6e995/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestUtil.java#L167-L180
Instead of sleeping the thread, we should instead use the already available waitForXXX()
methods that exist in the test utility.
Or for cases when we are going down an error path and need to wait for something to expire, we should perform polling to either fail, or succeed as quickly as possible.
There are instances where polling is already performed and the poll interval and duration are standardized to a constant here: https://github.com/jakartaee/concurrency/blob/cc64ec4fdac28f24145f8c99b4af55c8e1f6e995/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java#L33-L38
Consider introducing system properties to allow for implementations to specify their own interval and duration.