Mercurial > hg > Database > Christie
comparison src/main/java/christie/codegear/StartCodeGear.java @ 2:bacdcb5e6dcf
change StartCodeGear static
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Dec 2017 16:48:30 +0900 |
parents | 3ea61d0bfc34 |
children | e3bb0eea73f2 |
comparison
equal
deleted
inserted
replaced
1:3ea61d0bfc34 | 2:bacdcb5e6dcf |
---|---|
1 package christie.codegear; | 1 package christie.codegear; |
2 | 2 |
3 import java.util.HashMap; | |
3 import java.util.concurrent.LinkedBlockingQueue; | 4 import java.util.concurrent.LinkedBlockingQueue; |
4 import java.util.concurrent.ThreadPoolExecutor; | 5 import java.util.concurrent.ThreadPoolExecutor; |
5 import java.util.concurrent.TimeUnit; | 6 import java.util.concurrent.TimeUnit; |
6 | 7 |
7 public interface StartCodeGear { | 8 public interface StartCodeGear { |
8 default CodeGearManager createCodeGearManager(ThreadPoolExecutor exe){ | 9 HashMap<String, CodeGearManager> cgms = new HashMap<String, CodeGearManager>(); |
9 return new CodeGearManager(exe); | 10 ThreadPoolExecutor threadPool = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads |
11 Runtime.getRuntime().availableProcessors(), | |
12 Integer.MAX_VALUE, // keepAliveTime | |
13 TimeUnit.SECONDS, | |
14 new LinkedBlockingQueue<Runnable>()); | |
15 | |
16 static CodeGearManager createCGM(String name){ | |
17 CodeGearManager cgm = new CodeGearManager(threadPool); | |
18 cgms.put(name, cgm); | |
19 return cgm; | |
10 } | 20 } |
11 | 21 |
12 default ThreadPoolExecutor createThreadPool(){ | 22 static CodeGearManager getCGM(String name){ |
13 return new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(), // initial number of threads | 23 return cgms.get(name); |
14 Runtime.getRuntime().availableProcessors(), | |
15 Integer.MAX_VALUE, // keepAliveTime | |
16 TimeUnit.SECONDS, | |
17 new LinkedBlockingQueue<Runnable>()); | |
18 } | 24 } |
19 } | 25 } |