Java Thread Executor Create createThreadFactory(final String prefix)

Here you can find the source of createThreadFactory(final String prefix)

Description

create Thread Factory

License

Open Source License

Declaration

public static ThreadFactory createThreadFactory(final String prefix) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.concurrent.Executors;

import java.util.concurrent.ThreadFactory;

public class Main {
    public static ThreadFactory createThreadFactory(final String prefix) {
        return new ThreadFactory() {
            private final ThreadFactory defaultThreadFactory = Executors.defaultThreadFactory();
            private int i = 0;

            @Override/*  ww  w . j  ava 2  s  . c  o m*/
            public Thread newThread(Runnable r) {
                Thread t = this.defaultThreadFactory.newThread(r);
                t.setName(prefix + " #" + this.i);
                this.i++;
                return t;
            }
        };
    }
}

Related

  1. createExecutors(int numThreads)
  2. createExecutorService()
  3. createResourceRetrievalService( final String threadName)
  4. createSingleThreadExecutor(final String name)
  5. createStatisticsExecutor()
  6. getExecutor()
  7. getExecutor(int numTasks, int maxThreads)
  8. getExecutorService()
  9. getExecutorService()