/** * Update the name of the thread to reflect its current status, so we get some idea of what is * going on when looking at stack traces. See the class description for a list of what those * names can be. */ private synchronized void updateName() { String taskName = (job != null && job.getTask() != null ? job.getTask().toString() : "none"); switch (status) { case IDLE: setName("Idle-" + id); break; case RUNNING: setName(String.format("Running-%d (%s)", id, taskName)); break; case CANCELLED: setName(String.format("Cancelled-%d (%s)", id, taskName)); break; case ZOMBIE: setName(String.format("Zombie-%d (%s)", id, taskName)); break; default: setName("UNKNOWN" + id); } }
/** * Returns true if the task is canceled or if the task is not in the active pool * * @param task The task to check. * @return <code>true</code> if the task is canceled, <code>false</code> otherwise. */ public boolean isCanceled(ITask task) { synchronized (poolLock) { for (JobThread thread : activePool) { Operation job = thread.getJob(); if (job != null && job.getTask() == task) { return thread.getStatus() == Status.CANCELLED; } } return true; } }