os.failsafe.executor.utils.NamedThreadFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of failsafe-executor Show documentation
Show all versions of failsafe-executor Show documentation
Persistent executor service for Java
package os.failsafe.executor.utils;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
public class NamedThreadFactory implements ThreadFactory {
private final AtomicLong threadIndex = new AtomicLong(0);
private final String threadNamePrefix;
public NamedThreadFactory(String threadNamePrefix) {
this.threadNamePrefix = threadNamePrefix;
}
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setName(threadNamePrefix + threadIndex.getAndIncrement());
return thread;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy