Methods Summary |
---|
public boolean | isStopped()
return stopped;
|
public void | queueEvent(java.lang.Object event)Place the given object in the queue.
if (event != null)
events.put(event);
|
public void | run()
log.debug("Begin " + name + " Thread");
stopped = false;
while( !stopped )
{
try
{
blocking = true;
Object event = events.take();
blocking = false;
if (!stopped)
{
processor.processEvent(event);
}
}
catch(InterruptedException e)
{
blocking = false;
log.debug(name + " Thread interrupted", e);
if (stopped)
break;
}
catch (Throwable t)
{
log.error("Caught Throwable handling asynch events", t);
}
}
log.debug("End " + name + " Thread");
|
public void | start()Starts the handler thread.
handlerThread = new Thread(this, name + " Thread");
handlerThread.start();
|
public void | stop()Stops the handler thread.
stopped = true;
if (blocking)
handlerThread.interrupt(); // it's just waiting on the LinkedQueue
if (handlerThread.isAlive()) {
// Give it up to 100ms to finish whatever it's doing
try
{
handlerThread.join(100);
}
catch (Exception ignored) {}
}
if (handlerThread.isAlive())
handlerThread.interrupt(); // kill it
|