publicclass KillThread { staticvolatileThread tdThread; publicstaticvoid main (String[] args) throws Exception {
Timer t = new Timer();
// Start a mean event that kills the timer thread
t.schedule(new TimerTask() { publicvoid run() {
tdThread = Thread.currentThread(); thrownew ThreadDeath();
}
}, 0);
// Wait for mean event to do the deed and thread to die. try { do { Thread.sleep(100);
} while(tdThread == null);
} catch(InterruptedException e) {
}
tdThread.join();
// Try to start another event try { // Timer thread is dead now
t.schedule(new TimerTask() { publicvoid run() {
}
}, 0); thrownew Exception("We failed silently");
} catch(IllegalStateException e) { // Killing the Timer thread is equivalent to cancelling the Timer
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.