Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Main {
    private static ExecutorService executorService = null;
    private static final Lock lock = new ReentrantLock();

    public static final void initPool(int threadSize) {
        if (null == executorService) {
            lock.lock();
            try {
                executorService = Executors.newFixedThreadPool(threadSize);
            } finally {
                lock.unlock();
            }
        }
    }
}