345
|
1 package alice.test.concurrent;
|
|
2
|
|
3 import org.msgpack.type.ValueFactory;
|
|
4
|
|
5 import alice.codesegment.CodeSegment;
|
|
6
|
|
7 public class StartConcurrent extends CodeSegment {
|
|
8
|
|
9 private int count;
|
|
10
|
|
11 public StartConcurrent(int count) {
|
|
12 this.count = count;
|
|
13 }
|
|
14
|
|
15 @Override
|
|
16 public void run() {
|
|
17 int threadNum = Runtime.getRuntime().availableProcessors() * count;
|
|
18
|
|
19 AliceFinish cs1 = new AliceFinish(threadNum);
|
|
20 cs1.ds1.setKey("finish");
|
|
21
|
|
22 for (int i = 0; i < threadNum; i++) {
|
|
23 SleepCodeSegment cs2 = new SleepCodeSegment(i);
|
|
24 cs2.ds1.setKey("wait");
|
|
25 }
|
|
26
|
|
27 for (int i = 0; i < threadNum; i++) {
|
|
28 ods.put("local", "wait", ValueFactory.createNilValue());
|
|
29 }
|
|
30 }
|
|
31
|
|
32 }
|