shoddybattle.util
Class ThreadedQueue

java.lang.Object
  extended by shoddybattle.util.ThreadedQueue

public class ThreadedQueue
extends java.lang.Object

Java 1.5 has this built in as java.util.BlockingQueue, but the version we are using - 1.4 - does not. Here I roll my own simple version.


Nested Class Summary
static interface ThreadedQueue.QueueDelegate
          Callback used to handle items in the queue as they are pulled off.
 
Constructor Summary
ThreadedQueue(ThreadedQueue.QueueDelegate delegate)
          Creates a new instance of ThreadedQueue.
 
Method Summary
 void finalize()
          Just in case we forget to stop the queue, this method will save us.
 void post(java.lang.Object o)
          Post a message to the threaded queue.
 void start()
          Start the threaded queue.
 void stop()
          Stop the threaded queue.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadedQueue

public ThreadedQueue(ThreadedQueue.QueueDelegate delegate)
Creates a new instance of ThreadedQueue.

Parameters:
delegate - object to invoke for each item in the queue
Method Detail

start

public void start()
Start the threaded queue.


stop

public void stop()
Stop the threaded queue.


finalize

public void finalize()
              throws java.lang.Throwable
Just in case we forget to stop the queue, this method will save us.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

post

public void post(java.lang.Object o)
Post a message to the threaded queue.