Skip to content

Commit bb613d9

Browse files
committed
added volatile veriable and synchronizated to method
1 parent 42476ff commit bb613d9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/core/basesyntax/Counter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
public class Counter {
77
private static final Logger logger = LogManager.getLogger(Counter.class);
88
private static final String MESSAGE = "%20s, Thread # %2s, counter value %2d";
9-
private int value;
9+
private volatile int value;
1010

1111
public Counter(int value) {
1212
this.value = value;
1313
}
1414

15-
public void decreaseValue() {
15+
public synchronized void decreaseValue() {
1616
logger.info(String.format(MESSAGE,
1717
"Before decrementing", Thread.currentThread().getName(), value));
1818
value--;

0 commit comments

Comments
 (0)