On 9/3/13 11:56 PM, Jaroslav Bachorik wrote:
Ok, let's go back to the basics :) The reason for the test to fail intermittently are stale reads from the "waiting" variable. In order to minimize the changes it seems sufficient to make the "waiting" variable volatile to prevent the stale reads. The code modifying the "waiting" variable is already guarded by the semaphore so we are good there. The changes in Locks.java are about more consistent approach to waiting for a thread to enter a desired state. I took Erik's recommendation to just wait indefinitely for the desired thread state and let the harness deal with timeouts. The very simplified patch is at http://cr.openjdk.java.net/~jbachorik/6815130/webrev.03
This simple change looks good. There are a couple of other tests using ThreadExecutionSynchronizer. Not sure if they run into this intermittent issue; if so, similiar fix might apply - just to mention it. Anyway this fix is good to go.
I will file a task for JDK9 to remove ThreadExecutionSynchronizer and simplify java.lang.management tests using it.
Thanks for filing the bug for JDK9. Mandy