commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mauve patch


From: Archie Cobbs
Subject: Re: Mauve patch
Date: Tue, 6 Apr 2004 08:46:27 -0500 (CDT)

Sascha Brawer wrote:
> >     PhantomReference wr = try1 (q, harness);
> >     System.gc ();
> >+    Thread.yield();
> >+    System.gc ();
> > 
> >     Reference r = null;
> >     try
> 
> Does this really guarantee that the finalizer has run? Couldn't this also
> lead to any other thread, such as some VM-internal thread, without
> running the finalizer? If so, you might want to call Object.notify in the
> finalizer and Object.wait at the above code location.

This patch doesn't guarantee anything, and in general it's impossible
to make this test "correct" because the spec allows finalization and
reference enqueuing to happen after arbitrarily long delays.

For example, a JVM that *never* finalizes is still within the spec
(it would probably throw OutOfMemoryError's more readily though).

This patch simply makes the test "correct" for JC (and possibly
some other VM(s) out there). Since there's no way to *ensure* the
finalizer and reference enqueing thread(s) have run, we just try
to give them every opportunity to do so before declaring that their
work should be done.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]