
be.bagofwords.util.ExecutorServiceFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bow-utils Show documentation
Show all versions of bow-utils Show documentation
Utility classes that are used in the count-db project and other bow-* projects
The newest version!
package be.bagofwords.util;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
/**
* Created by Koen Deschacht ([email protected]) on 14/11/14.
*/
public class ExecutorServiceFactory {
private static final int DEFAULT_NUM_OF_THREADS = 8;
public static ExecutorService createExecutorService(String name) {
return createExecutorService(DEFAULT_NUM_OF_THREADS, name);
}
public static ExecutorService createExecutorService(int numberOfThreads, String name) {
return Executors.newFixedThreadPool(numberOfThreads, new ThreadFactory() {
private int threadNr = 0;
@Override
public synchronized Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName(name + "_" + threadNr++);
return t;
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy