It says that i need to implement the Message interface in 4th thread... But I do that aleady... Or not?
package pl.codegym.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 {
Thread0 thread0 = new Thread0();
Thread1 thread1 = new Thread1();
Thread2 thread2 = new Thread2();
Thread3 thread3 = new Thread3();
Thread4 thread4 = new Thread4();
Thread t0 = new Thread(thread0);
Thread t1 = new Thread(thread1);
Thread t2 = new Thread(thread2);
Thread t3 = new Thread(thread3);
Thread t4 = new Thread(thread4);
threads.add(t0);
threads.add(t1);
threads.add(t2);
threads.add(t3);
threads.add(t4);
}
public static void main(String[] args) {
}
public static class Thread0 implements Runnable{
@Override
public void run(){
int i = 0;
while(true){
i+=1;
}
}
}
public static class Thread1 implements Runnable{
@Override
public void run(){
while(true){
try{
Thread.sleep(10);
}catch(InterruptedException e){
System.out.println("InterruptedException");
}
}
}
}
public static class Thread2 implements Runnable{
@Override
public void run(){
while(true){
try{
System.out.println("Hurra");
Thread.sleep(500);
}catch(InterruptedException e){
}
}
}
}
public static class Thread3 implements Message, Runnable{
public static boolean check = false;
@java.lang.Override
public void showWarning() {
check = true;
}
public void run()
{
while(true) {
if (check == true) {
Thread.currentThread().stop();
}
}
}
}
public static class Thread4 implements Runnable{
BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
String linia = "";
int counter = 0;
@Override
public void run(){
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String linia = "";
int counter = 0;
do {
try {
linia = bufferedReader.readLine();
int cyfra = Integer.parseInt(linia);
counter+=cyfra;
}catch (NumberFormatException | IOException e){
e.getMessage();
}
}while (!linia.equals("N"));
System.out.println(counter);
}
}
}