Подскажите пожалуйста, почему валидатор принял такой код:
public void run() {
while (!isInterrupted()) {
System.out.println(this);
if (--countDownIndex == 0) return;
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Нить прервана");
}
Но не пропустил этот:
public void run() {
while (!isInterrupted()) {
System.out.println(this);
if (--countDownIndex == 0) return;
try {
sleep(10); // В чём отличие от Thread.sleep(10) ?
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Нить прервана");
}