diff src/main/java/christie/codegear/CodeGearManager.java @ 6:3dcfe63d6394

set type to DataGear by Annotation
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Wed, 27 Dec 2017 00:06:50 +0900
parents 5be6647b87d2
children 21372a589bd3
line wrap: on
line diff
--- a/src/main/java/christie/codegear/CodeGearManager.java	Thu Dec 14 20:46:18 2017 +0900
+++ b/src/main/java/christie/codegear/CodeGearManager.java	Wed Dec 27 00:06:50 2017 +0900
@@ -4,19 +4,15 @@
 import christie.datagear.LocalDataGearManager;
 import christie.datagear.RemoteDataGearManager;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Created by e125769 on 12/7/17.
  * CodeGearの実行
  */
 public class CodeGearManager{
-    private HashMap<String, DataGearManager>  dataGearManagers = new HashMap<String, DataGearManager>();
+    private ConcurrentHashMap<String, DataGearManager>  dataGearManagers = new ConcurrentHashMap<String, DataGearManager>();
     private ThreadPoolExecutor codeGearExecutor;
 
     public CodeGearManager(ThreadPoolExecutor exe) {
@@ -24,20 +20,8 @@
         codeGearExecutor = exe;
     }
 
-    public void submit(CodeGear cg){
-        codeGearExecutor.setThreadFactory(makeThreadFactory(Thread.MAX_PRIORITY));
-        codeGearExecutor.execute(cg);
-    }
-
-    private ThreadFactory makeThreadFactory(final int priority) {
-        return new ThreadFactory() {
-            @Override
-            public Thread newThread(Runnable r) {
-                Thread thread = new Thread(r);
-                thread.setPriority(priority);
-                return thread;
-            }
-        };
+    public DataGearManager getDGM(){
+        return dataGearManagers.get("local");
     }
 
     public DataGearManager getDGM(String dest){
@@ -47,4 +31,9 @@
     public void createRemoteDataGeareManager(String dist){
         dataGearManagers.put(dist, new RemoteDataGearManager());
     }
+
+    public void submit(CodeGear cg){
+        codeGearExecutor.execute(cg);
+    }
+
 }