private synchronized BackgroundCommandTask<?> getNextTask() {
		if (tasks.isEmpty()) {
			taskThread = null;
			return null;
		}
		return tasks.removeFirst();
	}
Cancel the currently running task and clear all commands that are scheduled to run. Block
until the currently running task ends.

@param monitor a monitor to cancel waiting for the task to finish
Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/mgr/ToolTaskManager.java