test/java/lang/ref/EarlyTimeout.java
Print this page
@@ -61,13 +61,13 @@
EarlyTimeout[] threads = new EarlyTimeout[THREADS_COUNT];
for (int i = 0; i < THREADS_COUNT; ++i) {
threads[i] = new EarlyTimeout();
threads[i].start();
}
- startedSignal.await();
referent = null;
System.gc();
+ startedSignal.await();
for (EarlyTimeout thread : threads) {
thread.join();
}
if (weakReference.get() != null) {
throw new RuntimeException("weakReference was not cleared");
@@ -80,11 +80,14 @@
}
if (thread.reference != null && thread.reference == weakReference) {
nonNullRefCount++;
}
}
- if (nonNullRefCount != 1) {
+ if (nonNullRefCount == 0) {
+ System.err.println("no references were removed from queue");
+ }
+ if (nonNullRefCount > 1) {
throw new RuntimeException("more than one references were removed from queue");
}
}
public void run() {