aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Chang <vichang@google.com>2024-04-17 16:36:12 +0100
committerVictor Chang <vichang@google.com>2024-04-17 23:28:02 +0000
commit61551eb2bbd2870302dcee676921018386c9cd67 (patch)
tree9cdff4eb952975859fa5112733ae00a5fd22023a
parentb9b0ab044faf36e5faf97a944073433a0527d498 (diff)
downloadlibcore-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.java10
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;