diff src/main/java/christie/codegear/StartCodeGear.java @ 5:5be6647b87d2

StartCodeGear implements Runnable to wait InputDataGear
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Thu, 14 Dec 2017 20:46:18 +0900
parents e3bb0eea73f2
children 3dcfe63d6394
line wrap: on
line diff
--- a/src/main/java/christie/codegear/StartCodeGear.java	Wed Dec 13 17:35:25 2017 +0900
+++ b/src/main/java/christie/codegear/StartCodeGear.java	Thu Dec 14 20:46:18 2017 +0900
@@ -1,28 +1,31 @@
 package christie.codegear;
 
 import java.util.HashMap;
-import java.util.Queue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-public abstract class StartCodeGear {
+public abstract class StartCodeGear implements Runnable {
     static HashMap<String, CodeGearManager> cgms = new HashMap<String, CodeGearManager>();
     static LinkedBlockingQueue<Runnable> taskQueue = new LinkedBlockingQueue<Runnable>();
-    static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads
+    static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads
             Runtime.getRuntime().availableProcessors(),
             Integer.MAX_VALUE, // keepAliveTime
             TimeUnit.SECONDS,
             taskQueue);
 
-
     public static CodeGearManager createCGM(String name){
-        CodeGearManager cgm = new CodeGearManager(threadPool);
+        CodeGearManager cgm = new CodeGearManager(threadPoolExecutor);
         cgms.put(name, cgm);
         return cgm;
     }
 
-    public static CodeGearManager getCGM(String name){
+    public CodeGearManager getCGM(String name){
         return cgms.get(name);
     }
+
+    public void execute(){
+        threadPoolExecutor.execute(this);
+    }
+
 }