get Thread Pool Executor - Android java.lang

Android examples for java.lang:Thread

Description

get Thread Pool Executor

Demo Code


//package com.book2s;

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

public class Main {
    private static ExecutorService executor;

    public static ExecutorService getThreadPoolExecutor() {
        if (executor == null) {
            executor = new ThreadPoolExecutor(2, 5, 60, TimeUnit.SECONDS,
                    new LinkedBlockingDeque<Runnable>(3));
        }//from   w w  w .j  ava2 s .c o  m
        return executor;
    }
}

Related Tutorials