annotate src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/test/TatsukiTreeMapGetThread.java @ 0:44465893e8b8

first Commit
author Kazuma
date Wed, 30 Nov 2016 01:47:55 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
1 package jp.ac.u_ryukyu.ie.cr.jungle.test;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
2
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
3 import jp.ac.u_ryukyu.ie.cr.jungle.data.treemap.TreeMap;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
4
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
5 import java.util.Optional;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
6
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
7
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
8 public class TatsukiTreeMapGetThread extends AbstractTreeMapThread {
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
9 TreeMap<Long, String> map;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
10 private long findCount;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
11 boolean loop = true;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
12
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
13 public TatsukiTreeMapGetThread(TreeMap<Long,String> map) {
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
14 this.map = map;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
15 }
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
16
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
17 @Override
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
18 public long getFindCount() {
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
19 System.out.println("thread count = " + findCount);
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
20 return findCount;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
21 }
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
22
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
23 @Override
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
24 public void set(boolean loop) {
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
25 this.loop = loop;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
26 }
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
27
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
28 @Override
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
29 public void run() {
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
30 while (loop) {
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
31 for (long count = 0 ; count < 1000; count++) {
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
32 Optional<String> value = map.get(count);
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
33 if (!value.isPresent())
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
34 System.out.println("error");
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
35 }
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
36 findCount++;
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
37 }
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
38 }
44465893e8b8 first Commit
Kazuma
parents:
diff changeset
39 }