Przykład
protected void finalize() throws Throwable {
try {
Runnable runnable = getRunnable();
Thread thread = new Thread(runnable);
thread.start();
}
finally {
super .finalize();
}
}

private Runnable getRunnable() {
return _runnable;
}

private transient Runnable _runnable;
Rozwiązanie
Użyj jawnie wywoływanej metody czyszczenia (cleanup) zamiast metody finalize().
public void free() {
Runnable runnable = getRunnable();
Thread thread = new Thread(runnable);
thread.start();
}

private Runnable getRunnable() {
return _runnable;
}

private transient Runnable _runnable;