RFR 6309226: TEST: java/lang/management/ThreadMXBean/SynchronizationStatistics.java didn't check Thread.sleep
Jaroslav Bachorik
jaroslav.bachorik at oracle.com
Tue Oct 22 04:03:48 PDT 2013
On 22.10.2013 09:58, David Holmes wrote:
> On 21/10/2013 9:55 PM, Jaroslav Bachorik wrote:
>> Please, review this small patch for a test failing due to the updated
>> implementation in JDK6.
>>
>> Issue: https://bugs.openjdk.java.net/browse/JDK-6309226
>> Webrev: http://cr.openjdk.java.net/~jbachorik/6309226/webrev.00/
>>
>> The test fails due to the change in mustang where
>> ThreadMXBean.getThreadInfo().getWaitedTime() and
>> ThreadMXBean.getThreadInfo().getWaitedCount() include Thread.sleep()
>> too. Unfortunately, Thread.sleep() is used throughout the test for
>> synchronization purposes and this breaks the test.
>>
>> In the patch I propose to replace Thread.sleep() with busy wait and
>> hinting the scheduler by Thread.yield(). While not very elegant it
>> successfully works around inclusion of unknown number of Thread.sleep()s
>> (they are called in loop).
>
> Not elegant and not completely reliable either. Probably adequate on a
> multi-core system but single-core and with some schedulers it could just
> be a busy spin.
:/ Ok, so I need to account for the Thread.sleep() calls made outside of
the test code but still reported by the ThreadMXBean. Not that elegant,
too, but at least should be reliable.
http://cr.openjdk.java.net/~jbachorik/6309226/webrev.01
-JB-
>
> David
>
>> Thanks,
>>
>> -JB-
More information about the serviceability-dev
mailing list