publicstaticclass ThreadPauser implements Runnable { public Semaphore sem_wakeup_main = new Semaphore(0); public Semaphore sem_wait = new Semaphore(0);
publicstatic Consumer<StackTrace.StackFrameData> makePrintStackFramesConsumer() throws Exception { final Method end_method = Test1917.class.getDeclaredMethod("run"); returnnew Consumer<StackTrace.StackFrameData>() { publicvoid accept(StackTrace.StackFrameData data) { if (TEST_PRINT_ALL) {
System.out.println(data);
} else { Package p = data.method.getDeclaringClass().getPackage(); // Filter out anything to do with the testing harness. if (p != null && p.equals(Test1917.class.getPackage())) {
System.out.printf("'%s' line: %d\n",
data.method,
Breakpoint.locationToLine(data.method, data.current_location));
} elseif (data.method.getDeclaringClass().equals(Semaphore.class)) {
System.out.printf("'%s' line: <NOT-DETERMINISTIC>\n", data.method);
}
}
}
};
}
publicstaticvoid run() throws Exception {
System.out.println("Recurring 5 times"); new RecurCount(5, new StackTraceGenerator(makePrintStackFramesConsumer())).run();
System.out.println("Recurring 5 times on another thread"); Thread thr = newThread( Thread.currentThread().getThreadGroup(), new RecurCount(5, new StackTraceGenerator(makePrintStackFramesConsumer())), "Recurring Thread 1", 10*1000000/* 10 mb*/);
thr.start();
thr.join();
System.out.println("Recurring 5 times on another thread. Stack trace from main thread!");
ThreadPauser pause = new ThreadPauser(); Thread thr2 = newThread( Thread.currentThread().getThreadGroup(), new RecurCount(5, pause), "Recurring Thread 2", 10*1000000/* 10 mb*/);
thr2.start();
pause.waitForOtherThreadToPause(); new StackTraceGenerator(thr2, makePrintStackFramesConsumer()).run();
pause.wakeupOtherThread();
thr2.join();
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 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.