Code Review 7021010: java/lang/Thread/ThreadStateTest.java fails intermittently
Alan.Bateman at oracle.com
Mon Jun 20 12:31:31 PDT 2011
Chris Hegarty wrote:
> java/lang/Thread/ThreadStateTest.java can fail with when
> checkThreadState finds an unexpected state.
> Exception in thread "main" java.lang.RuntimeException: MyThread
> expected to have TERMINATED but got RUNNABLE
> at ThreadStateTest.checkThreadState(ThreadStateTest.java:119)
> at ThreadStateTest.main(ThreadStateTest.java:96)
> There is a race between the thread being put in a specific state and
> the thread testing for that state. The test should retry the thread
> state check a number of times before failing. Also, some minor cleanup
> and update to use a more recent j.u.c reusable synchronization barrier.
The retry loop in checkThreadState make sense. Is the 100ms sleep a bit
excessive? The thread will likely get to the expected state in a
fraction of that time.
One question on the TERMINATED state. Given that the check is now moved
to after the join then could this be a simple getState check rather than
The clean-up to use Phaser looks good to me.
More information about the core-libs-dev