4 пункт?
подскажите как в main обратиться к методу showWarning()?
package com.javarush.task.task16.task1632;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Клубок
*/
public class Solution {
public static List<Thread> threads = new ArrayList<>(5);
static {
threads.add(new Thread(new Infinity()));
threads.add(new Thread(new Interrupt()));
threads.add(new Thread(new Ura()));
threads.add(new Thread(new StopMessage()));
threads.add(new Thread(new ReaderConsole()));
}
public static void main(String[] args) throws InterruptedException {
for (Thread threads: threads) {
threads.start();
}
Thread.sleep(6000);
}
}
class Infinity extends Thread {
@Override
public void run() {
int c = 0;
while (true) {
c++;
System.out.println(c);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class Interrupt extends Thread {
@Override
public void run() {
try {
Thread.sleep(100000);
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
}
class Ura extends Thread {
@Override
public void run() {
while (true) {
try {
System.out.println("Ура");
Thread.sleep(500);
} catch (InterruptedException e) {
}
}
}
}
class StopMessage extends Thread implements Message {
@Override
public void showWarning() {
interrupted();
}
@Override
public void run() {
while (!isInterrupted()) {
try {
sleep(1000);
System.out.println("sendMessage");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class ReaderConsole extends Thread {
@Override
public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
int sum = 0;
while (true) {
String string = reader.readLine();
if(string.equals("N")){
break;
}
int value = Integer.parseInt(string);
sum +=value;
}
System.out.println(sum);
} catch (IOException e) {
e.printStackTrace();
}
}
}