Java Code Examples for java.lang.ref.WeakReference#enqueue()

The following examples show how to use java.lang.ref.WeakReference#enqueue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeakReferenceArrayTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testRemoveEnqueuedReference() {
  addElement(new Object());
  WeakReference reference = myCollection.getReferences()[0];
  assertSame(reference.get(), myHolder.get(0));
  myHolder.clear();
  reference.enqueue();
  myCollection.remove(0);
  gc();
  checkForAliveCount(0);
  myCollection.getCorpseCount();
  reference = null;
  gc();
  checkForAliveCount(0);
}
 
Example 2
Source File: WeakReferenceArrayTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testRemoveNotEnqueuedReference() {
  addElement(new Object());
  WeakReference reference = myCollection.getReferences()[0];
  myCollection.remove(0);
  gc();
  myHolder.clear();
  reference.enqueue();
  gc();
  checkForAliveCount(0);
}