Here you can find the source of getScheduledExecutorService( final int maxNbThreads, final String name)
Parameter | Description |
---|---|
maxNbThreads | Maximum number of concurrent threads. |
name | The name of the threads. |
public static ScheduledExecutorService getScheduledExecutorService( final int maxNbThreads, final String name)
//package com.java2s; /*/* w ww.ja v a 2s . c o m*/ // This software is subject to the terms of the Eclipse Public License v1.0 // Agreement, available at the following URL: // http://www.eclipse.org/legal/epl-v10.html. // You must accept the terms of that agreement to use this software. // // Copyright (C) 2001-2005 Julian Hyde // Copyright (C) 2005-2012 Pentaho and others // All Rights Reserved. */ import java.util.concurrent.*; public class Main { /** * Creates an {@link ScheduledExecutorService} object backed by a * thread pool with a fixed number of threads.. * @param maxNbThreads Maximum number of concurrent * threads. * @param name The name of the threads. * @return An scheduled executor service preconfigured. */ public static ScheduledExecutorService getScheduledExecutorService( final int maxNbThreads, final String name) { 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; } }); } }