annotate src/main/java/alice/test/concurrent/StartConcurrent.java @ 345:8f71c3e6f11d

Change directory structure Maven standard
author sugi
date Wed, 16 Apr 2014 18:26:07 +0900
parents
children aefbe41fcf12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
345
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
1 package alice.test.concurrent;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
2
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
3 import org.msgpack.type.ValueFactory;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
4
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
5 import alice.codesegment.CodeSegment;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
6
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
7 public class StartConcurrent extends CodeSegment {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
8
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
9 private int count;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
10
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
11 public StartConcurrent(int count) {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
12 this.count = count;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
13 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
14
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
15 @Override
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
16 public void run() {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
17 int threadNum = Runtime.getRuntime().availableProcessors() * count;
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
18
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
19 AliceFinish cs1 = new AliceFinish(threadNum);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
20 cs1.ds1.setKey("finish");
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
21
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
22 for (int i = 0; i < threadNum; i++) {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
23 SleepCodeSegment cs2 = new SleepCodeSegment(i);
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
24 cs2.ds1.setKey("wait");
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
25 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
26
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
27 for (int i = 0; i < threadNum; i++) {
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
28 ods.put("local", "wait", ValueFactory.createNilValue());
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
29 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
30 }
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
31
8f71c3e6f11d Change directory structure Maven standard
sugi
parents:
diff changeset
32 }