Java Thread Executor Create createDefaultExecutorService()

Here you can find the source of createDefaultExecutorService()

Description

Returns a new thread pool configured with the default settings.

License

Open Source License

Return

A new thread pool configured with the default settings.

Declaration

public static ThreadPoolExecutor createDefaultExecutorService() 

Method Source Code

//package com.java2s;
/*//from   www. j a  v a2s. com
 * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;

public class Main {
    /**
     * Returns a new thread pool configured with the default settings.
     *
     * @return A new thread pool configured with the default settings.
     */
    public static ThreadPoolExecutor createDefaultExecutorService() {
        ThreadFactory threadFactory = new ThreadFactory() {
            private int threadCount = 1;

            public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                thread.setName("s3-transfer-manager-worker-" + threadCount++);
                return thread;
            }
        };
        return (ThreadPoolExecutor) Executors.newFixedThreadPool(10, threadFactory);
    }
}

Related

  1. createDaemonThreadFactory()
  2. createDefaultExecutorService(final String threadNamePrefix, final int parallel)
  3. createEventsOrderedDeliveryExecutor()
  4. createExecutor()
  5. createExecutor(final String file)