diff --git a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java index 1f7e28bd4..42529df44 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/TimedSemaphoreTest.java @@ -405,7 +405,7 @@ public int getPeriodEnds() { * Invokes the latch if one is set. */ @Override - public void acquire() throws InterruptedException { + public synchronized void acquire() throws InterruptedException { super.acquire(); if (latch != null) { latch.countDown(); @@ -416,11 +416,9 @@ public void acquire() throws InterruptedException { * Counts the number of invocations. */ @Override - protected void endOfPeriod() { + protected synchronized void endOfPeriod() { super.endOfPeriod(); - synchronized (this) { - periodEnds++; - } + periodEnds++; } /**