com.bbn.openmap.layer.vpf
Class RunQueue

java.lang.Object
  extended by java.lang.Thread
      extended by com.bbn.openmap.layer.vpf.RunQueue
All Implemented Interfaces:
java.lang.Runnable

public class RunQueue
extends java.lang.Thread

Implement a very basic thread scheduling mechanism. TerminatingRunnable objects get added to the queue. As the thread gets cpu time, it will sequentially dequeue and run the objects in the queue in a LIFO order. Duplicates are allowed in the queue. Run will get called exactly once for each enqueue call. Only one thread will run at a time. (The next object won't run until the previous one completes.)

See Also:
Runnable.run()

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
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RunQueue()
          default constructor.
RunQueue(boolean isDaemon, int priority, boolean autoStart)
          construct a thread in the default ThreadGroup with a few options set
RunQueue(java.lang.ThreadGroup tg)
          construct this thread in a particular ThreadGroup
RunQueue(java.lang.ThreadGroup tg, boolean isDaemon, int priority, boolean autoStart)
          construct a thread in the default ThreadGroup with a few options set
 
Method Summary
 void enqueue(TerminatingRunnable r)
          Add an object to the queue of threads to run
 void run()
          start going.
 
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

RunQueue

public RunQueue()
default constructor. priority and daemon status inherited from the calling thread. This thread is NOT started


RunQueue

public RunQueue(java.lang.ThreadGroup tg)
construct this thread in a particular ThreadGroup

Parameters:
tg - the ThreadGroup to be in. null means the current ThreadGroup

RunQueue

public RunQueue(boolean isDaemon,
                int priority,
                boolean autoStart)
construct a thread in the default ThreadGroup with a few options set

Parameters:
isDaemon - true means be a daemon thread, false means don't.
priority - the value to use when calling setPriority
autoStart - true means call this.start()
See Also:
Thread.start()

RunQueue

public RunQueue(java.lang.ThreadGroup tg,
                boolean isDaemon,
                int priority,
                boolean autoStart)
construct a thread in the default ThreadGroup with a few options set

Parameters:
tg - the ThreadGroup to be in
isDaemon - true means be a daemon thread, false means don't.
priority - the value to use when calling setPriority
autoStart - true means call this.start()
See Also:
Thread.start()
Method Detail

run

public void run()
start going. This function locks the queue, dequeues and item, unlocks the queue, and calls run on the object that was dequeued. if no object was on the queue, it waits on the queue. this function never exits.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

enqueue

public void enqueue(TerminatingRunnable r)
Add an object to the queue of threads to run

Parameters:
r - the object to add


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details