diff options
author | Victor Chang <vichang@google.com> | 2024-04-17 16:36:12 +0100 |
---|---|---|
committer | Victor Chang <vichang@google.com> | 2024-04-17 23:28:02 +0000 |
commit | 61551eb2bbd2870302dcee676921018386c9cd67 (patch) | |
tree | 9cdff4eb952975859fa5112733ae00a5fd22023a | |
parent | b9b0ab044faf36e5faf97a944073433a0527d498 (diff) | |
download | libcore-61551eb2bbd2870302dcee676921018386c9cd67.tar.gz |
Increase the time out for TimerTest
Bug: 332479178
Test: atest CtsLibcoreTestCases:org.apache.harmony.tests.java.util.TimerTest
Change-Id: Ic7e9ee4f9470b598bd6c4eb3fb90f3cbc34b382c
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/util/TimerTest.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/TimerTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/TimerTest.java index cf59881ebde..ce0ff300fa4 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/TimerTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/TimerTest.java @@ -979,11 +979,19 @@ public class TimerTest extends TestCase { Thread.sleep(400); Thread timerThread = threadRef.get(); + + // Check if the timer thread is still alive every 10ms for 2 seconds + for (int i = 0; i < 200; i++) { + if (!timerThread.isAlive()) { + break; + } + Thread.sleep(10); + } assertFalse(timerThread.isAlive()); } private class CheckIfExecutedOnTime extends TimerTask { - private static final int TOLERANCE_TIME = 100; + private static final int TOLERANCE_TIME = 300; private final AtomicBoolean executedOnTime; static final int SLEEPING_TIME = 10 * TOLERANCE_TIME; |