Code example for AtomicReference

Methods: getset

0
        sepFwrC.getConstructor(Object.class, sepFrqC);
    // The object that we will wrap in FinalizableWeakReference is a Stopwatch. 
    Class<?> sepStopwatchC = sepLoader.loadClass(Stopwatch.class.getName());
    assertSame(sepLoader, sepStopwatchC.getClassLoader());
    AtomicReference<Object> sepStopwatchA =
        new AtomicReference<Object>(sepStopwatchC.newInstance());
    AtomicReference<WeakReference<?>> sepStopwatchRef =
        new AtomicReference<WeakReference<?>>(
            sepFwrCons.newInstance(sepStopwatchA.get(), sepFrqA.get()));
    assertNotNull(sepStopwatchA.get());
    // Clear all references to the Stopwatch and wait for it to be gc'd. 
    sepStopwatchA.set(null);
    GcFinalization.awaitClear(sepStopwatchRef.get());
    // Return a weak reference to the parallel ClassLoader. This is the reference that should 
    // eventually become clear if there are no other references to the ClassLoader. 
    return new WeakReference<ClassLoader>(sepLoader);
  } 
 
  private void doTestUnloadable() throws Exception { 
    WeakReference<ClassLoader> loaderRef = useFrqInSeparateLoader();
Contextual code suggestions in your IDE  Get Codota for Java