package com.javarush.task.task16.task1620; import java.util.ArrayList; import java.util.List; /* Один для всех, все - для одного */ public class Solution { public static byte countThread = 3; static List<Thread> threads = new ArrayList<Thread>(countThread); public static void main(String[] args) throws InterruptedException { initThreadsAndStart(); Thread.sleep(3000); ourInterruptMethod(); } private static void ourInterruptMethod() { for (Thread thread : threads) { thread.interrupt();//add your code here - добавь код тут } } private static void initThreadsAndStart() { Water water = new Water("water"); for (int i = 0; i < countThread; i++) { threads.add(new Thread(water, "#" + i)); } for (int i = 0; i < countThread; i++) { threads.get(i).start(); } } public static class Water implements Runnable { private String sharedResource; public Water(String sharedResource) { this.sharedResource = sharedResource; } public void run() { Thread current = Thread.currentThread();//fix 2 variables - исправь 2 переменных boolean isCurrentThreadInterrupted = Thread.currentThread().isInterrupted(); String threadName = current.getName(); try { while (true) { System.out.println("Объект " + sharedResource + ", нить " + threadName); Thread.sleep(1000); } } catch (InterruptedException e) { } } } }