com.h3c.util.cache

## Class CacheCleaner

- java.lang.Object
- - java.lang.Thread
  - - com.h3c.util.cache.CacheCleaner

- All Implemented Interfaces:
    Runnable

      public final class CacheCleaner
      extends Thread

  Cleans up zombie references from `WeakValueCache` instances.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class java.lang.Thread

      `Thread.State, Thread.UncaughtExceptionHandler`

  - ### Field Summary

    - ### Fields inherited from class java.lang.Thread

      `MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CacheCleaner(ReferenceQueue<?> refQ, String namePostfix)` Constructs a cache cleaner for the given reference queue.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cease()` Issues a soft cease request for the thread to stop.
    `void` | `run()` The run method removes (zombie) references from the queue and purges the corresponding map entry from the cache's internal map.

    - ### Methods inherited from class java.lang.Thread

      `activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CacheCleaner

          public CacheCleaner(ReferenceQueue<?> refQ,
                      String namePostfix)

      Constructs a cache cleaner for the given reference queue. Note that the reference queue must only contain `CachedValueWeakReference` instances or a class cast exception will be thrown when the cleaner tries to process items on the queue. Note that type wildcard ( `? extends Object`) refers to the type of the referent of the weak reference, not the type of the weak reference.

      This thread is marked as a daemon, to allow the JVM to shutdown appropriately.

      Parameters:
        `refQ` - the reference queue to process.
        `namePostfix` - thread name postfix

  - ### Method Detail

    - #### run

          public void run()

      The run method removes (zombie) references from the queue and purges the corresponding map entry from the cache's internal map. When there is nothing on the queue, the thread blocks and waits.
      Specified by:
        `run` in interface `Runnable`
      Overrides:
        `run` in class `Thread`

    - #### cease

          public void cease()

      Issues a soft cease request for the thread to stop.

      This should be invoked when the system is being unloaded.

Copyright © 2014. All Rights Reserved.