From f1302eee85b89778ad5f21dc3392a1912c6eabb8 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Mon, 13 May 2024 10:04:11 +0100 Subject: [PATCH] Delay is on a best effort basis (#253) --- .../chronicle/threads/LongPauserTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/test/java/net/openhft/chronicle/threads/LongPauserTest.java b/src/test/java/net/openhft/chronicle/threads/LongPauserTest.java index 2ff165f48..d4574aa51 100644 --- a/src/test/java/net/openhft/chronicle/threads/LongPauserTest.java +++ b/src/test/java/net/openhft/chronicle/threads/LongPauserTest.java @@ -50,11 +50,18 @@ public void unpauseStopsPausing() throws InterruptedException { @Test public void testLongAsyncPauser() { final LongPauser pauser = new LongPauser(0, 0, 1, 1, TimeUnit.MILLISECONDS); - for (int i = 0; i < 5; i++) { - pauser.asyncPause(); - testUntilUnpaused(pauser, 1, TimeUnit.MILLISECONDS); - pauser.reset(); - testUntilUnpaused(pauser, 0, TimeUnit.MILLISECONDS); + boolean failedOnce = false; + for (int i = 0; i < 100; i++) { + try { + pauser.asyncPause(); + testUntilUnpaused(pauser, 1, TimeUnit.MILLISECONDS); + pauser.reset(); + testUntilUnpaused(pauser, 0, TimeUnit.MILLISECONDS); + } catch (AssertionError e) { + if (failedOnce) + throw e; + failedOnce = true; + } } }