Дпоможіть розібратися в пункті 1.4
Не можу викликати метод public void 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 Thread0());
threads.add(new Thread1());
threads.add(new Thread2());
threads.add(new Thread3());
threads.add(new Thread4());
}
public static void main(String[] args) {
threads.get(0).start();
threads.get(1).start();
threads.get(1).interrupt();
threads.get(2).start();
threads.get(3).start();
threads.get(4).start();
}
//--------------------1----------------------
public static class Thread0 extends Thread
{
boolean isRun = true;
@Override
public void run() {
while (isRun){}
}
}
//-------------------2-----------------------
public static class Thread1 extends Thread
{
@Override
public void run()
{
try {
throw new InterruptedException();
}catch (InterruptedException ie){
System.out.println("InterruptedException");}
}
}
//----------------3-------------------------
public static class Thread2 extends Thread
{
@Override
public void run() {
while(true)
{
try
{
System.out.println("Ура");
Thread.sleep(500);
}catch (InterruptedException ie){}
}
}
}
//-------------------------4------------------
public static class Thread3 extends Thread implements Message
{
private boolean isChange = true;
@Override
public void run() {
while(!isChange)
{
try
{
System.out.println("Ура");
Thread.sleep(500);
}catch (InterruptedException ie){}
}
}
@Override
public void showWarning()
{this.isChange = false;}
}
//-----------------5------------------------
public static class Thread4 extends Thread
{
@Override
public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int integer = 0;
while (true)
{
String s = null;
try {s = reader.readLine();}catch (Exception e){}
if (!s.equals("N")) {
int num = Integer.parseInt(s);
integer = integer + num;
}else break;
}System.out.println(integer);
}
}
}