public class Solution { public static void main(String[] args) throws InterruptedException { TestThread testThread = new TestThread(); testThread.start(); Thread.sleep(3000); testThread.interrupt(); } public static class TestThread extends Thread { public void run(){ Thread current = Thread.currentThread(); while (!current.isInterrupted()){ try { Thread.sleep(1000); //IDEA подсказывает, что ошибка здесь, но я не понимаю что не так? System.out.println("Tik-Tak"); } catch (InterruptedException e){ e.printStackTrace(); current.interrupt(); } } } } } Вывод: Tik-Tak Tik-Tak java.lang.InterruptedException: sleep interrupted at java.base/java.lang.Thread.sleep(Native Method) at com.company.Solution$TestThread.run(Solution.java:16)