Here you can find the source of getExecutorServiceWithThreadName(final String threadNamePrefix, int threadCount)
public static ScheduledExecutorService getExecutorServiceWithThreadName(final String threadNamePrefix, int threadCount)
//package com.java2s; /*/* w w w .ja v a 2s .c o m*/ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; public class Main { public static ScheduledExecutorService getExecutorServiceWithThreadName(final String threadNamePrefix, int threadCount) { return Executors.newScheduledThreadPool(threadCount, new ThreadFactory() { private int i = 1; @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName(threadNamePrefix + ":" + i++); return thread; } }); } }