@Override
public void run()
{
- if (!threadRunning()) {
- return; // stopped before it ever started. how can this be? we just got invoked.
- }
- try {
- while (true) {
- boolean keepGoing = performActivity();
- if (!keepGoing) {
- c_logger.debug("thread returned false for single shot thread. just saying.");
- }
- if (c_period == 0) {
- // not a periodic thread, so we're done now.
+ if (!threadRunning()) {
+ return; // stopped before it ever started. how can this be? we just got invoked.
+ }
+ try {
+ while (true) {
+ boolean keepGoing = performActivity();
+ if (!keepGoing) {
+ c_logger.debug("thread returned false for single shot thread. just saying.");
+ }
+ if (c_period == 0) {
+ // not a periodic thread, so we're done now.
+ break;
+ }
+ long nextRun = System.currentTimeMillis() + c_period;
+ while (System.currentTimeMillis() < nextRun) {
+ if (shouldStop()) {
break;
}
- long nextRun = System.currentTimeMillis() + c_period;
- while (System.currentTimeMillis() < nextRun) {
- if (shouldStop()) {
- break;
- }
- try {
- Thread.sleep(SNOOZE_PERIOD);
- } catch (InterruptedException e) {
- // well, we'll hit it again soon.
- }
+ try {
+ Thread.sleep(SNOOZE_PERIOD);
+ } catch (InterruptedException e) {
+ // well, we'll hit it again soon.
}
}
- } catch (Throwable t) {
- c_logger.info("exception thrown from performActivity: " + t.getLocalizedMessage(), t);
}
+ } catch (Throwable t) {
+ c_logger.info("exception thrown from performActivity: " + t.getLocalizedMessage(), t);
}
-
+ }
}
-