void () { fillWithObjects(20); assertEquals(20, myWeakList.listSize()); addElement(HARD_REFERENCED); assertEquals(21, myWeakList.listSize()); myHolder.clear(); while (myWeakList.toStrongList().size() == 21) { synchronized (myWeakList) { gc(); } } synchronized (myWeakList) { boolean processed = myWeakList.processQueue(); assertTrue(myWeakList.toStrongList().toString(), processed); // some refs must be in the queue } //HARD_REFERENCED is held there assertEquals(1, myWeakList.listSize()); assertSame(HARD_REFERENCED, myWeakList.iterator().next()); }