publicclass LoggingDeadlock4 { privatestatic CountDownLatch barrier = new CountDownLatch(1); privatestatic CountDownLatch lmIsRunning = new CountDownLatch(1); privatestatic CountDownLatch logIsRunning = new CountDownLatch(1);
// Create a sun.util.logging.PlatformLogger$JavaLogger object // that has to be redirected when the LogManager class // is initialized. This can cause a deadlock between // LogManager.<clinit> and Logger.getLogger(). privatestaticfinal sun.util.logging.PlatformLogger log =
sun.util.logging.PlatformLogger.getLogger("java.util.logging");
publicstaticvoid main(String[] args) {
System.out.println("main: LoggingDeadlock4 is starting.");
Thread lmThread = newThread("LogManagerThread") { publicvoid run() { // let main know LogManagerThread is running
lmIsRunning.countDown();
System.out.println(Thread.currentThread().getName()
+ ": is running.");
try {
barrier.await(); // wait for race to start
} catch (InterruptedException e) {
}
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.