java.lang.Object
ai.attackframework.tools.burp.utils.concurrent.EdtMonitor

public final class EdtMonitor extends Object
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:

  1. Every PROBE_INTERVAL_MS a tick on the monitor thread records a posted timestamp and submits SwingUtilities.invokeLater(Runnable) that records its run timestamp once the EDT actually executes it.
  2. 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 via Thread.getAllStackTraces() and emits a [EdtMonitor] log line. Repeat captures during the same stuck window are throttled to once per LAG_DUMP_THRESHOLD_MS so a 30 s freeze produces a handful of stack samples rather than a flood.
  3. 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 Classes
    Modifier and Type
    Class
    Description
    static final class 
    Test seam: small wallclock helper exposed for symmetry with chunk-log embedding.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Test seam: returns the current reference count.
    static boolean
    Test seam: returns whether the monitor is currently active.
    static void
    Test seam: forces all state back to clean for unit tests.
    static void
    Starts the monitor (or increments its reference count if already started).
    static void
    Decrements the reference count and stops the monitor when no callers remain.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.