1 // FinalizerThread.java -- Thread in which finalizers are run.
3 /* Copyright (C) 2001 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 package gnu.gcj.runtime;
14 * @author Tom Tromey <tromey@redhat.com>
15 * @date October 3, 2001
17 public final class FinalizerThread extends Thread
19 // Finalizers must be run in a thread with no Java-visible locks
20 // held. This qualifies because we don't make the lock visible.
21 private static final Object lock = new Object ();
23 // This is true if the finalizer thread started successfully. It
24 // might be false if, for instance, there are no threads on the
25 // current platform. In this situation we run finalizers in the
27 private static boolean thread_started = false;
29 public FinalizerThread ()
31 super ("LibgcjInternalFinalizerThread");
35 // This is called by the runtime when a finalizer is ready to be
36 // run. It simply wakes up the finalizer thread.
37 public static void finalizerReady ()
48 // Actually run the finalizers.
49 private static native void runFinalizers ();
53 // Wait on a lock. Whenever we wake up, try to invoke the
57 thread_started = true;
64 catch (InterruptedException _)
66 // Just ignore it. It doesn't hurt to run finalizers
67 // when none are pending.