System.out.println("Asking thread to park");
test.parkNow = true;
try { // Give some time to the ParkTester thread to honor the park command. Thread.sleep(3000);
} catch (InterruptedException ex) {
System.out.println("Main thread interrupted!");
System.exit(1);
}
if (test.success) {
System.out.println("Test succeeded!");
} else {
System.out.println("Test failed.");
test.printTimes();
System.out.println("Value of success = " + test.success); Thread.sleep(3000);
System.out.println("Value of success after sleeping = " + test.success);
test.printTimes(); // In case they weren't ready the first time.
}
}
/** *Setup{@link#UNSAFE}.
*/ publicstaticvoid setUp() throws Exception{ /* *SubverttheaccesschecktogettheuniqueUnsafeinstance. *Wecandothisbecausethere'snosecuritymanager *installedwhenrunningthetest.
*/
Field field = null; try {
field = Unsafe.class.getDeclaredField("THE_ONE");
} catch (NoSuchFieldException e1) { try {
field = Unsafe.class.getDeclaredField("theUnsafe");
} catch (NoSuchFieldException e2) { thrownew RuntimeException("Failed to find THE_ONE or theUnsafe");
}
}
field.setAccessible(true);
UNSAFE = (Unsafe) field.get(null);
}
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.