1
package com.javarush.task.task16.task1632;
import sun.awt.windows.ThemeReader;
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
{
Thread thread1=new Thread10();
Thread thread2=new Thread20();
Thread thread3=new Thread30();
Thread thread4=new Thread40();
Thread thread5=new Thread50();
threads.add(thread1);
threads.add(thread2);
threads.add(thread3);
threads.add(thread4);
threads.add(thread5);
}
public static void main(String[] args) {
}
public static class Thread10 extends Thread {
public void run(){
while(true){}
}
}
public static class Thread20 extends Thread {
public void run(){
try {
throw new InterruptedException();
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
}
public static class Thread30 extends Thread{
public void run(){
while (true){
try {
System.out.println("Ура");
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public static class Thread40 extends Thread implements Message {
public void showWarning() {
interrupt();
}
public void run () {
showWarning();
}
}
public static class Thread50 extends Thread{
int summa=0;
ArrayList<Integer> list=new ArrayList<>();
public void run(){
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
try {
while(true) {
String text = reader.readLine();
if (text != "N") {
int chislo=Integer.parseInt(text);
list.add(chislo);
} else {
reader.close();
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
for (int i = 0; i <list.size() ; i++) {
summa+=list.get(i);
}
System.out.println(summa);
}
}
}