JDK 9 RFR of JDK-8132548: java/lang/ThreadGroup/Stop.java fails with "RuntimeException: Failure"
Martin Buchholz
martinrb at google.com
Tue Jul 12 17:03:57 UTC 2016
This message is only the reviewers having friendly discussion with each
other!
On Mon, Jul 11, 2016 at 11:44 PM, David Holmes <david.holmes at oracle.com>
wrote:
> private static final AtomicReference<Throwable> firstThrowable
>> = new AtomicReference<>();
>> private static final AtomicReference<Throwable> secondThrowable
>> = new AtomicReference<>();
>>
>
> Simple volatile Throwable fields would suffice - AtomicReferences are
> overkill.
>
>
But in my later attempt they became locals, which is better style when
possible.
> private static final Thread second = new Thread(group, () -> {
>> ready.countDown();
>> try {
>>
>
> You have to place the countDown() inside the try block else the
> ThreadDeath may escape.
>
>
Oh good point - there's a race window!
(everybody writes racy code)
> do {} while (true);
>>
>
> Busy-loops are "bad".
>
Occasionally necessary, but yes, should be used only as last resort. But
here it's not clear which is more wasteful of cpu time...
> I agree this meets the "spec" of checking "did group.stop() cause all
> group members to encounter a ThreadDeath exception". But in relation to
> fixing the original timing problem, well a simple untimed-join() fixed that.
>
>
I like to throw in extra assertions when I've gone to the trouble of
setting up a test scenario.
More information about the core-libs-dev
mailing list