Когда я пересматриваю старый код, я натолкнулся на него.Будет ли лучше использовать isInterrupted вместо прерванного в следующем случае
public void stop() {
if (this.simulationThread != null) {
this.simulationThread.interrupt();
try {
this.simulationThread.join();
}
catch (InterruptedException exp) {
log.error(null, exp);
}
this.simulationThread = null;
}
}
public void run() {
while (!Thread.interrupted() && simulationThread == Thread.currentThread()) {
}
}
Мне было интересно, будет ли это лучше использовать, или это не имеет значения?
public void run() {
Thread t = Thread.currentThread();
// Will it better to use isInterrupted, since it will not clear the interrupt
// flag?
while (!t.isInterrupted() && simulationThread == t) {
}
}