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

David Holmes david.holmes at oracle.com
Thu Oct 30 07:31:51 UTC 2014


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.

Thanks,
David

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



More information about the core-libs-dev mailing list