public class Apple {
@Override
protected void finalize() throws Throwable {
super.finalize();
Thread.sleep(130*1000);
}
}
Cree un objeto A pple en actividad.
Interceptar excepciones en C rash Handler
import android.util.Log;
import androidx.annotation.NonNull;
import java.util.concurrent.TimeoutException;
public class Te implements Thread.UncaughtExceptionHandler {
@Override
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable ex) {
if (thread.getName().equals("FinalizerWatchdogDaemon") && (ex instanceof TimeoutException || ex.getMessage().contains("timed out"))) {
return; //Ignore
}
}
}
Se informarán dos excepciones, a saber, RuntimeException y TimeoutException
uncaughtException thread.getName FinalizerWatchdogDaemon ## ex.getMessage (.Apple.finalize () agotado después de 10 segundos ## ex.getClass (). getName () java.util.concurrent.TimeoutException
uncaughtException thread.getName FinalizerWatchdogDaemon ## ex.getMessage (java.util.concurrent.TimeoutException: .Apple.finalize () agotado después de 10 segundos ## ex.getClass (). getName () java.lang.RuntimeException