public final class ThreadUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
formatStackTrace(Thread thread) |
static String |
getCurrentThreadIdentifier() |
static String |
getThreadIdentifier(Thread thread) |
static void |
logAllThreads()
Logs a stack trace for all threads currently running in the JVM, similar to jstack.
|
static void |
shutdownAndAwaitTermination(ExecutorService pool,
long timeoutMs)
From https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ExecutorService.html
The following method shuts down an ExecutorService in two phases, first by calling shutdown to
reject incoming tasks, and then calling shutdownNow, if necessary, to cancel any lingering
tasks.
|
public static String formatStackTrace(Thread thread)
thread
- a threadpublic static void logAllThreads()
public static void shutdownAndAwaitTermination(ExecutorService pool, long timeoutMs)
pool
- the executor service to shutdowntimeoutMs
- how long to wait for the service to shut downpublic static String getCurrentThreadIdentifier()
Copyright © 2023. All Rights Reserved.