- 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 (!threadAlive()) {
+ 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, signifying it wants to exit. now dropping it.");
+ break;
+ }
+ 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()) {