1 package ch.hslu.exercises.sw08.ex2;
2
3
4 import java.util.concurrent.atomic.AtomicInteger;
5
6 public final class AtomicCounter implements Counter {
7
8 private final AtomicInteger count;
9
10
11
12
13 public AtomicCounter() {
14 this.count = new AtomicInteger(0);
15 }
16
17
18
19
20 @Override
21 public int increment() {
22 return count.incrementAndGet();
23 }
24
25
26
27
28 @Override
29 public int decrement() {
30 return count.decrementAndGet();
31 }
32
33
34
35
36 @Override
37 public int get() {
38 return count.get();
39 }
40 }