I'm aware of this question here but I have a slightly different question. If I wish to hand-code via the various Thread methods myself (not via utility classes or Quartz) the running of a Thread at a particular time, then what would be the most efficient (in terms of overhead) to code this.
I considered:
boolean wasInterrupted = false;
while (System.currentTimeMillis() < executionTimeInMillis) {
try {
Thread.sleep(X);
} catch (InterruptedException ie) {
wasInterrupted = true;
}
}
if (!wasInterrupted) {
doMyThing();
}
Is there a better way? Is this primitive and naive?