RFR (s): 4354680: Runtime.runFinalization() silently clears interrupted flag in the calling thread

Chris Hegarty chris.hegarty at oracle.com
Thu Oct 30 09:21:46 UTC 2014


On 30 Oct 2014, at 07:31, David Holmes <david.holmes at oracle.com> wrote:

> On 30/10/2014 4:00 PM, Stanimir Simeonoff wrote:
>> 
>>    Aside, I noticed in this code:
>> 
>>      146         forkSecondaryFinalizer(new Runnable() {
>>      147             private volatile boolean running;
>>      148             public void run() {
>>      149                 if (running)
>>      150                     return;
>>      151                 final JavaLangAccess jla =
>>    SharedSecrets.__getJavaLangAccess();
>>      152                 running = true;
>> 
>>    that as we create a new Runnable on every call, the "running" field
>>    serves absolutely no purpose.
>> 
>>    Cheers,
>>    David
>> 
>> It could be defense vs Thread.currentThread().run() in finalizer that
>> would cause calling run() of Thread.target. I am not sure if that would
>> cause invocation, though.
> 
> That is an excellent point! But it deserves a comment in the code.

Adding a comment is fine, but please to not remove this field. ‘hg log’ may reveal more about it’s origins.

-Chris.

> Thanks,
> David
> 
>> But I have done similar "non-senses"...
>> 
>> Stanimir




More information about the core-libs-dev mailing list