1 package ch.hslu.exercises.sw08.ex2;
2
3 import java.util.concurrent.Callable;
4
5
6
7
8 public class CountTask implements Callable<Integer> {
9
10 private final Counter counter;
11 private final int counts;
12
13
14
15
16
17
18
19 public CountTask(Counter counter, int counts) {
20 this.counter = counter;
21 this.counts = counts;
22 }
23
24 @Override
25 public Integer call() {
26 for (int i = 0; i < counts; i++) {
27 counter.increment();
28 }
29 for (int i = 0; i < counts; i++) {
30 counter.decrement();
31 }
32 return counter.get();
33 }
34 }