Index: vm/tests/smoke/gc/WeakReferenceTest.java =================================================================== --- vm/tests/smoke/gc/WeakReferenceTest.java (revision 501758) +++ vm/tests/smoke/gc/WeakReferenceTest.java (working copy) @@ -45,15 +45,24 @@ System.gc(); System.out.println("waiting for a reference.."); - Reference enqueued = queue.poll(); + // wait a little before calling poll() + Reference enqueued; + int count = 500; + do { + try { + Thread.sleep(20); + } catch (Exception e) { + } + enqueued = queue.poll(); + } while (enqueued == null && count-- > 0); + if (count == 0) { + System.out.println("FAIL: reference was not enqueued"); + return; + } if (ref.get() != null) { System.out.println("FAIL: reference was not cleared."); return; } - if (enqueued == null) { - System.out.println("FAIL: reference was not enqueued"); - return; - } if (enqueued.get() != null) { System.out.println("FAIL: reference was not cleared."); return; Index: vm/tests/smoke/gc/PhantomReferenceTest.java =================================================================== --- vm/tests/smoke/gc/PhantomReferenceTest.java (revision 501758) +++ vm/tests/smoke/gc/PhantomReferenceTest.java (working copy) @@ -41,15 +41,24 @@ System.gc(); System.out.println("waiting for a reference.."); - Reference enqueued = queue.poll(); + // wait a little before calling poll() + Reference enqueued; + int count = 500; + do { + try { + Thread.sleep(20); + } catch (Exception e) { + } + enqueued = queue.poll(); + } while (enqueued == null && count-- > 0); + if (count == 0) { + System.out.println("FAIL: reference was not enqueued"); + return; + } if (ref.get() != null) { System.out.println("FAIL: reference was not cleared."); return; } - if (enqueued == null) { - System.out.println("FAIL: reference was not enqueued"); - return; - } if (enqueued.get() != null) { System.out.println("FAIL: reference was not cleared."); return;