Package slash.navigation.gui.helpers
Class BackgroundExecutor
java.lang.Object
slash.navigation.gui.helpers.BackgroundExecutor
A single, bounded, named thread pool for fire-and-forget background work that has no
result to hand back to the EDT.
Work that updates Swing state should use a SwingWorker instead, so the
EDT hand-off goes through the framework's done() rather than a hand-rolled
invokeLater.
Pool threads are named rc-worker-<n> and are daemon threads, so they never keep the
JVM alive. While a submitted task runs, its thread is temporarily renamed to
rc-worker-<n>[<taskName>] so a thread dump (jstack) or a crash report taken during
the task shows what the pool was doing, not just which of the bounded set of pool threads it
was on; the thread's name is restored once the task finishes.
- Author:
- Christian Pesch
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidStops accepting new work and interrupts running tasks.static voidSubmits fire-and-forgettaskto the shared pool.
-
Method Details
-
submit
Submits fire-and-forgettaskto the shared pool. An exception escaping the task is logged, not rethrown, and does not affect other tasks or the pool itself.- Parameters:
taskName- a short, stable name for the task, used only to enrich the thread's name for the duration of the run (e.g. for crash telemetry and thread dumps)task- the work to run
-
shutdownNow
public static void shutdownNow()Stops accepting new work and interrupts running tasks. Called from the application's shutdown path.
-