From b3a71716b85d7ba747f70a0d2fb1bd36a0711462 Mon Sep 17 00:00:00 2001 From: Kamil Jan Mularski Date: Wed, 31 Dec 2025 18:20:12 +0100 Subject: [PATCH] Make decreaseValue method synchronized Added the synchronized keyword to the decreaseValue method in Counter to ensure thread safety when decrementing the value. --- src/main/java/core/basesyntax/Counter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/core/basesyntax/Counter.java b/src/main/java/core/basesyntax/Counter.java index 4af46bd4..feb1ad7d 100644 --- a/src/main/java/core/basesyntax/Counter.java +++ b/src/main/java/core/basesyntax/Counter.java @@ -12,7 +12,7 @@ public Counter(int value) { this.value = value; } - public void decreaseValue() { + public synchronized void decreaseValue() { logger.info(String.format(MESSAGE, "Before decrementing", Thread.currentThread().getName(), value)); value--;