Instead of the running flag (which can be checked using the public isRunning method) being set at the start and the end of the run logic, it is instead set within the startCancelThread and endCancelThread:
private void startCancelThread() {
// Start a cancel thread if there is a program running and a timeout value has been specified.
if (timeOut_ != 0) {
// Set a flag that a program is running.
running_ = true;
// Create a thread to do the cancel if needed. Start the thread.
cancelThread_ = new ProgramCallCancelThread(this);
cancelThread_.setDaemon(true);
cancelThread_.start();
}
}
This seems counterintuitive, as it results in the running flag always being false if no timeout was specified. The javadoc for the isRunning method also does not specify that it only works when a timeout was given.