Java Utililty Methods Thread Factory

List of utility methods to do Thread Factory

Description

The list of methods to do Thread Factory are organized into topic(s).

Method

ScheduledExecutorServicegetScheduledExecutorService(final int maxNbThreads, final String name)
Creates an ScheduledExecutorService object backed by a thread pool with a fixed number of threads..
return Executors.newScheduledThreadPool(maxNbThreads, new ThreadFactory() {
    public Thread newThread(Runnable r) {
        final Thread thread = Executors.defaultThreadFactory().newThread(r);
        thread.setDaemon(true);
        thread.setName(name);
        return thread;
});
...
ThreadFactorygetThreadFactory(String name)
Based on the default thread factory
return r -> {
    Thread t = Executors.defaultThreadFactory().newThread(r);
    t.setName(name + "-" + t.getName()); 
    return t;
};
ThreadFactorygetThreadFactory(String nameFormat, boolean daemon)
Get a ThreadFactory suitable for use in the current environment.
ThreadFactory threadFactory = MoreExecutors.platformThreadFactory();
return new ThreadFactoryBuilder().setThreadFactory(threadFactory).setDaemon(daemon)
        .setNameFormat(nameFormat).build();