Java Thread Executor Create getExecutorService()

Here you can find the source of getExecutorService()

Description

get Executor Service

License

Open Source License

Declaration

public static synchronized ExecutorService getExecutorService() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2008 Tasktop Technologies 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
 *
 * Contributors:/*from   w w  w  . j  a v  a  2s. c o  m*/
 *     Tasktop Technologies - initial API and implementation
 *     Michael Valenta - improvements
 *******************************************************************************/

import java.util.concurrent.ExecutorService;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Main {
    private static final int MAX_CONCURRENT_REQUESTS = 100;
    private static ExecutorService service;

    public static synchronized ExecutorService getExecutorService() {
        if (service == null) {
            service = new ThreadPoolExecutor(1, MAX_CONCURRENT_REQUESTS, 10L, TimeUnit.SECONDS,
                    new SynchronousQueue<Runnable>());
        }
        return service;
    }
}

Related

  1. createThreadFactory(final String prefix)
  2. getExecutor()
  3. getExecutor(int numTasks, int maxThreads)
  4. getExecutorService()
  5. getExecutorService()
  6. getExecutorService(int maximumPoolSize, int corePoolSize, long keepAliveTime, final String name, RejectedExecutionHandler rejectionPolicy)
  7. getExecutorService(int poolSize)
  8. getExecutorService(String usage)
  9. getExecutorServiceWithThreadName(final String threadNamePrefix, int threadCount)