Code Review 6562203: Thread doesn't terminate immediately if it was stopped before start

David Holmes David.Holmes at
Tue Feb 15 00:53:19 UTC 2011

HI Chris, Alan,

Alan Bateman said the following on 02/15/11 03:48:
> Chris Hegarty wrote:
>> Since your changes for CR 6566340 "Restore use of stillborn flag to 
>> signify a thread that was stopped before it started", are now promoted 
>> in hs21.0-b01, I would like to proceed with this clean up in the 
>> libraries. Basically reverse out the changes that were made by CR 
>> 4519200, in JDK6. Stop before start will now be correctly handled 
>> solely by the VM.
>> Also, some minor changes to an existing StopBeforeStart regression test.
> Not your doing, but it looks like stop(null) could resume a suspended 
> thread before throwing NPE. Do I read this correctly? Just wondering if 
> that should be ex-examined while you are in the stop method.

It doesn't pay to look too closely at this code :)

Yes the old and current code might resume a thread and then not actually 
stop it due to the throwable being null. We should probably put in an 
explicit null check.

That said the resume() is bogus anyway:

1. There's nothing in the spec that says that a thread that was 
suspended which is then stopped should immediately resume so that it can 
throw the exception. Seems to me it should throw only after being 
explicitly resumed.

2. As there's no synchronization between stop/suspend/resume the thread 
could be suspended as soon as you've resumed it.

That aside the code changes look code.

Thanks. Let's hope we've finally laid this one to rest!


More information about the core-libs-dev mailing list