5555
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;
import java.util.Scanner;
/*
Клубок
*/
public class Solution {
public static List<Thread> threads = new ArrayList<>(5);
static {
threads.add(new Infinyti());
threads.add(new InterruptedExcetion());
threads.add(new Ura());
threads.add(new MessageA());
threads.add(new Naq());
}
public static void main(String[] args) {
for (Thread r: threads) {
r.start();
}
}
static class Infinyti extends Thread{
@Override
public void run(){
while (true){
}
}
}
static class InterruptedExcetion extends Thread{
@Override
public void run() {
try {
throw new InterruptedException();
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
}
static class Ura extends Thread{
@Override
public void run() {
while (true) {
System.out.println("Ура");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
static class MessageA extends Thread implements Message{
public static volatile boolean isStop = false;
@Override
public void run(){
while (!isStop) {
}
}
public void showWarning() {
isStop = true;
}
}
static class Naq extends Thread{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int r = 0;
@Override
public void run(){
try {
String str = reader.readLine();
if (str.equals("N")){
r += Integer.parseInt(str);
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(r);
}
}
}