I have a problem with this task, it won't exit loop, what should I do?
package pl.codegym.task.task16.task1619;
/*
Bez przerywania, nic z tego?
*/
public class Solution {
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(new TestThread());
t.start();
Thread.sleep(3000);
ourInterrupt();
}
public static void ourInterrupt() throws InterruptedException {
Thread t = Thread.currentThread();
t.interrupt();
}
public static class TestThread implements Runnable {
public void run() {
Thread t = Thread.currentThread();
while (!t.isInterrupted()) {
try {
System.out.println("he, he");
Thread.sleep(500);
} catch (InterruptedException e) {
}
}
}
}
}