public class Solution {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new TestThread());
        t.start();
        Thread.sleep(3000);
        ourInterruptMethod();
    }
    public static volatile boolean isInterrupted=false;
    public static void ourInterruptMethod() {
         isInterrupted=true;
    }

    public static class TestThread implements Runnable {
        public void run() {
            while (!isInterrupted) {
                try {
                    System.out.println("he-he");
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                }
            }
        }
    }
}
По моим представлениям переменная isInterrupted должна быть обязательно volatile. Так как обращение к ней идет из TestThread, а изменение в main. Это ведь долны быть две разные переменные для каждого потока, но работает и без модификатора и с ним. Подскажите, в чем дело