mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Add NamedThreadFactory to ThreadUtils
This commit is contained in:
parent
1c94099de9
commit
8bd4317f94
@ -19,6 +19,7 @@
|
||||
package org.sleuthkit.autopsy.coreutils;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/*
|
||||
@ -50,6 +51,35 @@ final public class ThreadUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A thread factory that allows for the creation of distinctly named task
|
||||
* threads by an ExecutorService constructed using an Executors factory
|
||||
* method. Each thread created using the factory will be named using the
|
||||
* thread name and a numerical suffix.
|
||||
*/
|
||||
public static class NamedThreadFactory implements ThreadFactory {
|
||||
|
||||
private final String threadName;
|
||||
|
||||
/**
|
||||
* Contructs a thread factory that allows for the creation of distinctly
|
||||
* named task threads by an ExecutorService constructed using an
|
||||
* Executors factory method. Each thread created using the factory will
|
||||
* be named using the thread name and a numerical suffix.
|
||||
*
|
||||
* @param threadName The name of the threads.
|
||||
*/
|
||||
public NamedThreadFactory(String threadName) {
|
||||
this.threadName = threadName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable task) {
|
||||
return new Thread(task, threadName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ThreadUtils() {
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user