// Try to resume ourself. try {
Suspension.resume(Thread.currentThread());
} catch (Exception e) { if (!e.getMessage().equals("JVMTI_ERROR_THREAD_NOT_SUSPENDED")) {
System.out.println("incorrect error for resuming a non-suspended thread");
}
} try {
Suspension.resume(other);
} catch (Exception e) { if (!e.getMessage().equals("JVMTI_ERROR_THREAD_NOT_SUSPENDED")) {
System.out.println("incorrect error for resuming a non-suspended thread");
}
}
Suspension.suspend(other); // Wait 1 second for the other thread to suspend.
waitForSuspension(other);
OTHER_THREAD_DID_SOMETHING = false; // Wait a second to see if anything happens.
waitFor(1000);
if (OTHER_THREAD_DID_SOMETHING) {
System.out.println("Looks like other thread did something while suspended!");
} // Resume always.
Suspension.resume(other);
// Wait another second.
waitFor(1000);
if (!OTHER_THREAD_DID_SOMETHING) {
System.out.println("Doesn't look like the thread unsuspended!");
}
// Stop the other thread.
OTHER_THREAD_CONTINUE = false; // Wait for 1 second for it to die.
other.join(1000);
if (other.isAlive()) {
System.out.println("other thread didn't terminate in a reasonable time!");
Runtime.getRuntime().halt(1);
}
} catch (Throwable t) {
System.out.println( "something was thrown. Runtime might be in unrecoverable state: " + t);
t.printStackTrace();
Runtime.getRuntime().halt(2);
}
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-29)
¤
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.