+ 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;
+ }
+ 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);
+ }