// Pop a Task entry from the task queue and check if the task's thread has finished.
// If it has completed then call onComplete for the task.
// If it has not completed then push the task back on the queue.
public boolean processTaskQueue() {
boolean processed = false;
Task task = this.taskQueue.poll();
if (task != null) {
if (task.isDone()) {
task.printException();
task.onComplete();
processed = true;
} else {
// put entry back on top of queue
this.taskQueue.push(task);
}