Java examples for java.util.concurrent:ThreadFactory
create Thread Factory
//package com.java2s; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; public class Main { public static ThreadFactory createThreadFactory(final String prefix) { return new ThreadFactory() { private AtomicInteger size = new AtomicInteger(); @Override/*from ww w . ja va 2 s.c om*/ public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName(prefix + size.incrementAndGet()); if (thread.isDaemon()) { thread.setDaemon(false); } //thread.setPriority(9); return thread; } }; } }