Class CleanupThread

  extended by java.lang.Thread
      extended by org.eclipse.ocl.examples.eventmanager.framework.CleanupThread
All Implemented Interfaces:

public class CleanupThread
extends java.lang.Thread

Observes a reference queue and removes Adapters from it. It weakly references an EventManagerTableBased. When a reference to an adapter was added to the queue and henceforth removed by this thread, this means that the adapter is no longer strongly referenced. A EventManagerTableBased.deregister(Reference) is issued to clean up after the adapter.

When the event manager becomes eligible for garbage collection, its EventManagerTableBased.finalize() method stops this thread by calling stopCleaner().

Axel Uhl (d043530)

Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
Field Summary
Fields inherited from class java.lang.Thread
Constructor Summary
CleanupThread(java.lang.ref.ReferenceQueue<org.eclipse.emf.common.notify.Adapter> adaptersNoLongerStronglyReferenced, EventManagerTableBased eventManager)
Method Summary
 void run()
 void stopCleaner()
          Indirectly but cleanly stops this thread.
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


public CleanupThread(java.lang.ref.ReferenceQueue<org.eclipse.emf.common.notify.Adapter> adaptersNoLongerStronglyReferenced,
                     EventManagerTableBased eventManager)
Method Detail


public void stopCleaner()
Indirectly but cleanly stops this thread. This happens by nulling the stopThreadAdapter field which was the only strong reference to the adapter held by it. The weak reference in stopThreadMarker will therefore be enqueued which serves as the stop marker, causing the run() loop to terminate.


public void run()
Specified by:
run in interface java.lang.Runnable
run in class java.lang.Thread