blob: 0e1d5c9b705c52777d5dc4eb17956fec51472a16 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package com.it_jaros.jscanner.scan;
import java.util.concurrent.atomic.AtomicInteger;
public final class Counter {
private final AtomicInteger current = new AtomicInteger(0);
private final AtomicInteger max = new AtomicInteger(0);
private final AtomicInteger total = new AtomicInteger(0);
public void inc() {
total.incrementAndGet();
int now = current.incrementAndGet();
max.accumulateAndGet(now, Math::max);
}
public void dec() {
current.decrementAndGet();
}
public int current() {
return current.get();
}
public int max() {
return max.get();
}
public int total() {
return total.get();
}
}
|