@@ -36,23 +36,19 @@ public class StatsItemSetTest {
36
36
37
37
@ Test
38
38
public void test_getAndCreateStatsItem_multiThread () throws InterruptedException {
39
- for (int i = 0 ; i < 50 ; i ++) {
40
- assertEquals (20000L , test_unit ().longValue ());
41
- }
39
+ assertEquals (20L , test_unit ().longValue ());
42
40
}
43
41
44
42
@ Test
45
43
public void test_getAndCreateMomentStatsItem_multiThread () throws InterruptedException {
46
- for (int i = 0 ; i < 50 ; i ++) {
47
- assertEquals (10 , test_unit_moment ().longValue ());
48
- }
44
+ assertEquals (10 , test_unit_moment ().longValue ());
49
45
}
50
46
51
47
private AtomicLong test_unit () throws InterruptedException {
52
48
final StatsItemSet statsItemSet = new StatsItemSet ("topicTest" , scheduler , null );
53
- executor = new ThreadPoolExecutor (100 , 200 , 10 , TimeUnit .SECONDS ,
54
- new ArrayBlockingQueue <Runnable >(10000 ), new ThreadFactoryImpl ("testMultiThread" ));
55
- for (int i = 0 ; i < 10000 ; i ++) {
49
+ executor = new ThreadPoolExecutor (10 , 20 , 10 , TimeUnit .SECONDS ,
50
+ new ArrayBlockingQueue <Runnable >(100 ), new ThreadFactoryImpl ("testMultiThread" ));
51
+ for (int i = 0 ; i < 10 ; i ++) {
56
52
executor .submit (new Runnable () {
57
53
@ Override
58
54
public void run () {
@@ -61,7 +57,7 @@ public void run() {
61
57
});
62
58
}
63
59
while (true ) {
64
- if (executor .getCompletedTaskCount () == 10000 ) {
60
+ if (executor .getCompletedTaskCount () == 10 ) {
65
61
break ;
66
62
}
67
63
Thread .sleep (1000 );
@@ -71,9 +67,9 @@ public void run() {
71
67
72
68
private AtomicLong test_unit_moment () throws InterruptedException {
73
69
final MomentStatsItemSet statsItemSet = new MomentStatsItemSet ("topicTest" , scheduler , null );
74
- executor = new ThreadPoolExecutor (100 , 200 , 10 , TimeUnit .SECONDS ,
75
- new ArrayBlockingQueue <Runnable >(10000 ), new ThreadFactoryImpl ("testMultiThread" ));
76
- for (int i = 0 ; i < 10000 ; i ++) {
70
+ executor = new ThreadPoolExecutor (10 , 20 , 10 , TimeUnit .SECONDS ,
71
+ new ArrayBlockingQueue <Runnable >(100 ), new ThreadFactoryImpl ("testMultiThread" ));
72
+ for (int i = 0 ; i < 10 ; i ++) {
77
73
executor .submit (new Runnable () {
78
74
@ Override
79
75
public void run () {
@@ -82,7 +78,7 @@ public void run() {
82
78
});
83
79
}
84
80
while (true ) {
85
- if (executor .getCompletedTaskCount () == 10000 ) {
81
+ if (executor .getCompletedTaskCount () == 10 ) {
86
82
break ;
87
83
}
88
84
Thread .sleep (1000 );
0 commit comments