//Now I say that Christ has been made a servant of the circumcision for the truth of God, that he might confirm the promises given to the fathers (Romans 15:8) package com.javarush.task.task16.task1625; /* ÐÐ·Ð°Ð¸Ð¼Ð½Ð°Ñ Ð±Ð»Ð¾ÐºÐ¸Ñовка */ public class Solution { static Thread t1 = new T1(); static Thread t2 = new T2(); public static void main(String[] args) throws InterruptedException { t1.start(); t1.interrupt(); t2.start(); t2.interrupt(); } public static class T1 extends Thread { @Override public void run() { try { t2.join(); System.out.println("T1 finished"); } catch (InterruptedException e) { System.out.println("T1 was interrupted"); } } } public static class T2 extends Thread { @Override public void run() { try { t1.join(); System.out.println("T2 finished"); } catch (InterruptedException e) { System.out.println("T2 was interrupted"); } } } } /* ÐÐ·Ð°Ð¸Ð¼Ð½Ð°Ñ Ð±Ð»Ð¾ÐºÐ¸Ñовка 1. РазбеÑиÑÑ, как ÑабоÑÐ°ÐµÑ Ð¿ÑогÑамма. 2. Ðе менÑÑ ÐºÐ»Ð°ÑÑÑ T1 и T2 Ñделай Ñак, ÑÑÐ¾Ð±Ñ Ð¸Ñ Ð½Ð¸Ñи завеÑÑилиÑÑ, не обÑзаÑелÑно ÑÑпеÑно. 3. ÐеÑод sleep не иÑполÑзоваÑÑ. ТÑебованиÑ: 1.âÐеÑод main должен запÑÑкаÑÑ Ð½Ð¸ÑÑ t1. 2.âÐеÑод main должен запÑÑкаÑÑ Ð½Ð¸ÑÑ t2. 3.âÐлаÑÑ T1 не изменÑÑÑ. 4.âÐлаÑÑ T2 не изменÑÑÑ. 5.âÐеÑод sleep не иÑполÑзоваÑÑ. 6.âÐÑвод пÑогÑÐ°Ð¼Ð¼Ñ Ð´Ð¾Ð»Ð¶ÐµÐ½ ÑоÑÑоÑÑÑ Ð¸Ð· 2Ñ ÑÑÑок, инÑоÑмиÑÑÑÑÐ¸Ñ Ð¾ завеÑÑении ниÑей. ÐапÑимеÑ: "T1 was interrupted" и "T2 finished". 7.âÐиÑи t1 и t2 Ð´Ð¾Ð»Ð¶Ð½Ñ Ð·Ð°Ð²ÐµÑÑаÑÑÑÑ (не обÑзаÑелÑно ÑÑпеÑно). package com.javarush.task.task16.task1625; * ÐÐ·Ð°Ð¸Ð¼Ð½Ð°Ñ Ð±Ð»Ð¾ÐºÐ¸Ñовка * public class Solution { static Thread t1 = new T1(); static Thread t2 = new T2(); public static void main(String[] args) throws InterruptedException { t1.start(); t2.start(); } public static class T1 extends Thread { @Override public void run() { try { t2.join(); System.out.println("T1 finished"); } catch (InterruptedException e) { System.out.println("T1 was interrupted"); } } } public static class T2 extends Thread { @Override public void run() { try { t1.join(); System.out.println("T2 finished"); } catch (InterruptedException e) { System.out.println("T2 was interrupted"); } } } } */