void () { int N = 200; fillWithObjects(N); String x = new String("xxx"); addElement(x); fillWithObjects(N); gc(); assertEquals(N + 1 + N, myWeakList.listSize()); myHolder.clear(); while (myWeakList.toStrongList().size() == N + 1 + N) { synchronized (myWeakList) { gc(); } } boolean removed = myWeakList.remove("zzz"); assertFalse(removed); assertEquals(1, myWeakList.listSize()); Object element = myWeakList.iterator().next(); assertSame(x, element); }