Mercurial > hg > Members > nobuyasu > Alice > DPPAlice
comparison src/alice/test/dpp/codesegment/ThinkCodeSegment.java @ 13:888388e47fe5
modified ThinkCodeSegment. remove random, sleep
author | one |
---|---|
date | Wed, 28 Nov 2012 16:21:34 +0900 |
parents | bfaaebb50a2e |
children | 33727db069c2 |
comparison
equal
deleted
inserted
replaced
12:bfaaebb50a2e | 13:888388e47fe5 |
---|---|
21 @Override | 21 @Override |
22 public void run() { | 22 public void run() { |
23 System.out.println(phil.getName() + " thinking"); | 23 System.out.println(phil.getName() + " thinking"); |
24 Fork leftFork = arg1.asClass(Fork.class); | 24 Fork leftFork = arg1.asClass(Fork.class); |
25 Fork rightFork = arg2.asClass(Fork.class); | 25 Fork rightFork = arg2.asClass(Fork.class); |
26 double rand = Math.random(); | 26 new TakeForkCodeSegment(phil); |
27 if (rand < 0.5) { | |
28 try { | |
29 Thread.sleep(10); | |
30 new ThinkCodeSegment(phil); | |
31 } catch (InterruptedException e) { | |
32 e.printStackTrace(); | |
33 } | |
34 } else { | |
35 new TakeForkCodeSegment(phil); | |
36 } | |
37 | |
38 ods.update("local", leftFork.getForkName(), leftFork); | 27 ods.update("local", leftFork.getForkName(), leftFork); |
39 ods.update("local", rightFork.getForkName(), rightFork); | 28 ods.update("local", rightFork.getForkName(), rightFork); |
40 } | 29 } |
41 | 30 |
42 } | 31 } |