package com.greensnow25.threadPool;

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

/**
 * Public class SimpleThreadPool.
 *
 * @author greensnow25.
 * @version 1.
 * @since 10.07.2017.
 */
public class SimpleThreadPool {


    public void makePool() {
        int count = Runtime.getRuntime().availableProcessors();

        ExecutorService service = Executors.newFixedThreadPool(count);
        for (int i = 0; i != 100; i++) {
            service.submit(new Work(i));
        }


        System.out.println(count);
    }

    public static void main(String[] args) {
        SimpleThreadPool stp = new SimpleThreadPool();
        stp.makePool();
    }

    /**
     * usefull
     */
    private class Work implements Runnable {
        /**
         * count .
         */
        int count;

        /**
         * constructor.
         *
         * @param count count.
         */
        public Work(int count) {
            this.count = count;
        }

        /**
         * run.
         */
        @Override
        public void run() {
            System.out.println(count);
        }
    }
}

@@ -292,16 +292,112 @@
 Pool %7B%0A%0A
+    /**%0A     * method create ThreadPool equal to the number of processors in the system.%0A     */
 %0A    pub
@@ -646,26 +646,24 @@
       %7D%0A
-%0A%0A
         
 System.o
@@ -658,41 +658,94 @@
     
-System.out.println(count);%0A    %7D%0A
+service.shutdown();%0A    %7D%0A%0A    /**%0A     * main.%0A     *%0A     * @para args args.%0A     */
 %0A   
@@ -891,15 +891,46 @@
   * 
-usefull
+inner class useful work, do something.
 %0A   

Update date 11.07.2017