提交 0c4934e6 authored 作者: Thomas Mueller's avatar Thomas Mueller

Require Java 6

上级 c26fc592
...@@ -21,7 +21,6 @@ class DatabaseCloser extends Thread { ...@@ -21,7 +21,6 @@ class DatabaseCloser extends Thread {
private final Trace trace; private final Trace trace;
private volatile WeakReference<Database> databaseRef; private volatile WeakReference<Database> databaseRef;
private int delayInMillis; private int delayInMillis;
private boolean stopImmediately;
DatabaseCloser(Database db, int delayInMillis, boolean shutdownHook) { DatabaseCloser(Database db, int delayInMillis, boolean shutdownHook) {
this.databaseRef = new WeakReference<Database>(db); this.databaseRef = new WeakReference<Database>(db);
...@@ -38,25 +37,9 @@ class DatabaseCloser extends Thread { ...@@ -38,25 +37,9 @@ class DatabaseCloser extends Thread {
synchronized (this) { synchronized (this) {
databaseRef = null; databaseRef = null;
} }
ThreadGroup threadGroup = getThreadGroup();
// the threadGroup could be null if the thread was run in the meantime
if (threadGroup != null && threadGroup.activeCount() > 100) {
// in JDK 1.4 and below, all Thread objects are added to the ThreadGroup,
// and cause a memory leak if never started.
// Need to start it, otherwise it leaks memory in JDK 1.4 and below
stopImmediately = true;
try {
start();
} catch (Throwable e) {
// ignore
}
}
} }
public void run() { public void run() {
if (stopImmediately) {
return;
}
while (delayInMillis > 0) { while (delayInMillis > 0) {
try { try {
int step = 100; int step = 100;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论