We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 42476ff commit bb613d9Copy full SHA for bb613d9
1 file changed
src/main/java/core/basesyntax/Counter.java
@@ -6,13 +6,13 @@
6
public class Counter {
7
private static final Logger logger = LogManager.getLogger(Counter.class);
8
private static final String MESSAGE = "%20s, Thread # %2s, counter value %2d";
9
- private int value;
+ private volatile int value;
10
11
public Counter(int value) {
12
this.value = value;
13
}
14
15
- public void decreaseValue() {
+ public synchronized void decreaseValue() {
16
logger.info(String.format(MESSAGE,
17
"Before decrementing", Thread.currentThread().getName(), value));
18
value--;
0 commit comments