Class ReferenceQueueConsumer

java.lang.Object
java.lang.Thread
org.apache.sis.internal.system.ReferenceQueueConsumer
All Implemented Interfaces:
Runnable

public final class ReferenceQueueConsumer extends Thread
A thread processing all Reference instances enqueued in a ReferenceQueue. This is the central place where every weak references produced by the SIS library are consumed. This thread will invoke the Disposable.dispose() method for each references enqueued by the garbage collector. Those references must implement the Disposable interface. Example:
Since:
0.3
Version:
0.3
Author:
Martin Desruisseaux (Geomatys)
  • Field Details

    • QUEUE

      public static final ReferenceQueue<Object> QUEUE
      List of references collected by the garbage collector. This reference shall be given to Reference constructors as documented in the class javadoc. Those Reference sub-classes must implement the Disposable interface.
  • Method Details

    • run

      public final void run()
      Loop to be run during the virtual machine lifetime. Public as an implementation side-effect; do not invoke explicitly!
      Specified by:
      run in interface Runnable
    • isStalled

      protected boolean isStalled()
      Returns true if this thread seems to be blocked for a time long enough for suspecting a problem. The default implementation always returns false. Subclasses are encouraged to provide some problem detection mechanism here if they can. For example if the head of a queue seems to be never removed, then maybe the process consuming that queue is blocked.
      Returns:
      true if this thread seems to be stalled.
    • isKillRequested

      protected final boolean isKillRequested()
      Returns true if this daemon thread shall terminate. This happen at shutdown time.
      Returns:
      true if this daemon thread shall terminate.