Race condition in TimerTask KillThread test
gary.adams at oracle.com
Fri Nov 4 15:52:01 UTC 2011
I'm taking a look at some older timing based bugs that may cause problems
on slower machines
6818464: TEST_BUG: Timeout values in several java/util tests are insufficient
I'd like to split this bug into two, based on the example problems that are
mentioned in the bug report.
The first example in
is a legitimate race condition. The code only will work
correctly if the processing for the TimerTask schedules
and fires the runnable within the hard coded
100 milliseconds. This can be fixed with a local variable
to synchronize when the the second operation can be
attempted. (Hard coded sleep times are rarely correct
when dealing with slower devices.)
In the second example the test instructions present a timeout
to be enforced by the outer test harness. e.g.
@run main/timeout=20 StoreDeadLock
This type of test limit is easily addressed on slower machines
using the test harness timefactor to scale the acceptable
test run time.
I'll attempt a simple fix for the KillThread case by replacing :
with a simple loop
} while (waiting);
where the TimerTask runnable will clear the flag
with "waiting = false " once it has been launched.
More information about the core-libs-dev