< prev index next >
src/java.base/share/classes/java/lang/ref/Finalizer.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -58,15 +58,11 @@
}
private void remove() {
synchronized (lock) {
if (unfinalized == this) {
- if (this.next != null) {
unfinalized = this.next;
- } else {
- unfinalized = this.prev;
- }
}
if (this.next != null) {
this.next.prev = this.prev;
}
if (this.prev != null) {
@@ -110,11 +106,11 @@
}
/* Create a privileged secondary finalizer thread in the system thread
group for the given Runnable, and wait for it to complete.
- This method is used by both runFinalization and runFinalizersOnExit.
+ This method is used by both runFinalization.
The former method invokes all pending finalizers, while the latter
invokes all uninvoked finalizers if on-exit finalization has been
enabled.
These two methods could have been implemented by offloading their work
@@ -162,35 +158,10 @@
}
}
});
}
- /* Invoked by java.lang.Shutdown */
- static void runAllFinalizers() {
- if (VM.initLevel() == 0) {
- return;
- }
-
- forkSecondaryFinalizer(new Runnable() {
- private volatile boolean running;
- public void run() {
- // in case of recursive call to run()
- if (running)
- return;
- final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
- running = true;
- for (;;) {
- Finalizer f;
- synchronized (lock) {
- f = unfinalized;
- if (f == null) break;
- unfinalized = f.next;
- }
- f.runFinalizer(jla);
- }}});
- }
-
private static class FinalizerThread extends Thread {
private volatile boolean running;
FinalizerThread(ThreadGroup g) {
super(g, null, "Finalizer", 0, false);
}
< prev index next >