Class EdtMonitor
java.lang.Object
ai.attackframework.tools.burp.utils.concurrent.EdtMonitor
Monitors Event Dispatch Thread (EDT) responsiveness during long-running snapshots so we can
tell whether observed UI freezes are caused by JVM-wide stop-the-world pauses, EDT-only
starvation (snapshot thread busy, EDT idle but not scheduled), or a specific blocking call
holding the EDT.
The monitor runs on a dedicated daemon thread and uses a self-pinging probe pattern:
- Every
PROBE_INTERVAL_MSa tick on the monitor thread records a posted timestamp and submitsSwingUtilities.invokeLater(Runnable)that records its run timestamp once the EDT actually executes it. - If the most recently posted probe has not yet been processed and the gap exceeds
LAG_DUMP_THRESHOLD_MS, the monitor captures the EDT stack viaThread.getAllStackTraces()and emits a[EdtMonitor]log line. Repeat captures during the same stuck window are throttled to once perLAG_DUMP_THRESHOLD_MSso a 30 s freeze produces a handful of stack samples rather than a flood. - A new probe is only posted when the previous one has run, so probes never queue up behind a frozen EDT and inflate apparent recovery time.
The class is intentionally a small, dependency-free static singleton: snapshot reporters
call start() when their loop begins and stop() when it ends. Multiple
concurrent snapshots are reference-counted so the monitor survives across overlapping
start/stop pairs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classTest seam: small wallclock helper exposed for symmetry with chunk-log embedding. -
Method Summary
Modifier and TypeMethodDescriptionstatic intTest seam: returns the current reference count.static booleanTest seam: returns whether the monitor is currently active.static voidTest seam: forces all state back to clean for unit tests.static voidstart()Starts the monitor (or increments its reference count if already started).static voidstop()Decrements the reference count and stops the monitor when no callers remain.
-
Method Details
-
start
public static void start()Starts the monitor (or increments its reference count if already started).Safe to call from any thread. Reference-counted so overlapping snapshot lifecycles do not race; the underlying scheduler only stops once
stop()has been called the same number of times. -
stop
public static void stop()Decrements the reference count and stops the monitor when no callers remain.Safe to call from any thread; mismatched stops (more stops than starts) are tolerated and treated as no-ops so accidental double-stops cannot leak a scheduler.
-
isRunningForTests
public static boolean isRunningForTests()Test seam: returns whether the monitor is currently active. -
activeRefsForTests
public static int activeRefsForTests()Test seam: returns the current reference count. -
resetForTests
public static void resetForTests()Test seam: forces all state back to clean for unit tests.
-