//that with one accord you may with one mouth glorify the God and Father of our Lord Jesus Christ (Romans 15:6) package com.javarush.task.task16.task1619; /* Рбез interrupt Ñлабо? */ 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 void ourInterruptMethod() { TestThread.isCancel = true; } public static class TestThread implements Runnable { public static boolean isCancel = false; public void run() { while (!isCancel) { try { System.out.println("he-he"); Thread.sleep(500); } catch (InterruptedException e) { } } } } } /* Рбез interrupt Ñлабо? РазбеÑиÑÑ, как ÑабоÑÐ°ÐµÑ Ð¿ÑогÑамма. Сделай Ñак, ÑÑÐ¾Ð±Ñ Ð² меÑоде ourInterruptMethod можно бÑло ÑделаÑÑ Ñак, ÑÑÐ¾Ð±Ñ Ð½Ð¸ÑÑ TestThread завеÑÑилаÑÑ Ñама. ÐелÑÐ·Ñ Ð¸ÑполÑзоваÑÑ Ð¼ÐµÑод interrupt. ТÑебованиÑ: 1.âРклаÑÑе Solution должен бÑÑÑ Ð¿ÑблиÑнÑй ÑÑаÑиÑеÑкий меÑод ourInterruptMethod без паÑамеÑÑов. 2.âÐеÑод run должен вÑводиÑÑ Ð½Ð°Ð´Ð¿Ð¸ÑÑ "he-he" каждÑе пол ÑекÑндÑ, пока не бÑÐ´ÐµÑ Ð²Ñзван меÑод ourInterruptMethod. 3.âÐÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ измениÑÑ ÑÑловие Ñикла while в меÑоде run. 4.âÐеÑод main должен ÑоздаваÑÑ Ð¾Ð±ÑÐµÐºÑ Ñипа Thread пеÑÐµÐ´Ð°Ð²Ð°Ñ Ð² конÑÑÑÑкÑÐ¾Ñ Ð¾Ð±ÑÐµÐºÑ Ñипа TestThread. 5.âÐеÑод main должен вÑзÑваÑÑ Ð¼ÐµÑод start Ñ Ð¾Ð±ÑекÑа Ñипа Thread. 6.âÐеÑод main должен вÑзÑваÑÑ Ð¼ÐµÑод ourInterruptMethod. package com.javarush.task.task16.task1619; /* Рбез interrupt Ñлабо? */ 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 void ourInterruptMethod() { } public static class TestThread implements Runnable { public void run() { while (true) { try { System.out.println("he-he"); Thread.sleep(500); } catch (InterruptedException e) { } } } } } */