diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-02-18 22:40:52 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-02-18 22:40:52 +0000 |
commit | b87a2c8e03bb12e89e41a8284ae6c8c6941c78fa (patch) | |
tree | 94af493e74def92054a4eef3439888f48e562a1c /harmony-tests/src/test | |
parent | 83594c625358e4e91eca3f9147c9975786ebe23e (diff) | |
parent | e7b8456e69c72dffc1c561c68cc320abfa6af241 (diff) | |
download | libcore-b87a2c8e03bb12e89e41a8284ae6c8c6941c78fa.zip libcore-b87a2c8e03bb12e89e41a8284ae6c8c6941c78fa.tar.gz libcore-b87a2c8e03bb12e89e41a8284ae6c8c6941c78fa.tar.bz2 |
Merge "Make ReferenceQueueTest#test_removeJ more robust."
Diffstat (limited to 'harmony-tests/src/test')
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java index 75a5218..e010116 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ref/ReferenceQueueTest.java @@ -22,6 +22,7 @@ import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; +import java.util.concurrent.CountDownLatch; import libcore.java.lang.ref.FinalizationTester; public class ReferenceQueueTest extends junit.framework.TestCase { @@ -198,27 +199,29 @@ public class ReferenceQueueTest extends junit.framework.TestCase { assertNull(rq.poll()); class RemoveThread extends Thread { + public final CountDownLatch inBlock = new CountDownLatch(1); + public final CountDownLatch outOfBlock = new CountDownLatch(1); public void run() { try { + inBlock.countDown(); rq.remove(1000L); } catch(InterruptedException ie) { isThrown = true; } + outOfBlock.countDown(); } } RemoveThread rt = new RemoveThread(); rt.start(); try { + rt.inBlock.await(); + // Try to be inside of rq.remove(1000L) if possible. Thread.sleep(10); - } catch(InterruptedException ie) { - - } + } catch(InterruptedException ie) {} rt.interrupt(); try { - Thread.sleep(10); - } catch(InterruptedException ie) { - - } + rt.outOfBlock.await(); + } catch(InterruptedException ie) {} assertTrue(isThrown); assertNull(rq.poll()); |