Почему не работает цикл while {}?

Рейтинг: 0Ответов: 2Опубликовано: 22.10.2014

Подскажите, пожалуйста, почему while{thread.sleep(1)} работает, а while{} нет. Разве программа не должна компилироваться также?

public class Just_tell_me_why {
static int [] list = new int[51];
public static void main(String[] args) throws InterruptedException {
    Counter counter = new Counter();
    counter.start();
    while (list[50]!=50){

    }

    for (int x:list) System.out.print(x + " ");

}
public static class Counter extends Thread{
    public void run(){
        for (int i = 0; i < list.length; i++) {
            list[i]=i;
            try {
                Thread.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

     }
    }
}

Ответы

Ответов пока нет.