get ScheduledExecutorService - Java java.util.concurrent

Java examples for java.util.concurrent:ScheduledExecutorService

Description

get ScheduledExecutorService

Demo Code


//package com.java2s;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getScheduler());
    }//from w  ww  .j  ava  2s . co  m

    private static ScheduledExecutorService POOL = Executors
            .newScheduledThreadPool(20);
    static int THREADS = 0;

    public static ScheduledExecutorService getScheduler() {

        if (POOL.isShutdown() || POOL.isTerminated()) {

            POOL = Executors.newScheduledThreadPool(10);

        }

        THREADS++;
        //Log.d("ThreadHelper", "thread count :" + THREADS);

        return POOL;

    }
}

Related Tutorials