Solves a race condition between start() on the class and run() on the internal SchedulerTask.

This commit is contained in:
Marius Bogoevici
2008-09-25 04:56:26 +00:00
parent 60e245f5a6
commit 3e675ca2e5

View File

@@ -104,8 +104,8 @@ public class SimpleTaskScheduler implements TaskScheduler {
if (this.running) {
return;
}
this.executor.execute(this.schedulerTask);
this.running = true;
this.executor.execute(this.schedulerTask);
}
finally {
this.lifecycleLock.unlock();
@@ -119,7 +119,7 @@ public class SimpleTaskScheduler implements TaskScheduler {
return;
}
this.running = false;
Thread executingThread = this.schedulerTask.executingThread.getAndSet(null);
Thread executingThread = this.schedulerTask.executingThread.get();
if (executingThread != null) {
executingThread.interrupt();
}
@@ -165,6 +165,7 @@ public class SimpleTaskScheduler implements TaskScheduler {
break;
}
}
this.executingThread.set(null);
}
}