I know this question here , but I have a slightly different question. If I want to manually pass through various Thread methods (and not through utility classes or Quartz) the Thread start at a certain point in time, then what would be the most effective (in terms of overhead) for encoding it.
I thought:
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 it primitive and naive?
Chris source
share