Нить 3 из списка threads должна каждые полсекунды выводить "Ура".
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 myThread());
threads.add(new myThread2());
threads.add(new myThread3());
threads.add(new myThread4());
threads.add(new myThread5());
}
static class myThread extends Thread{
public void run() {
while (true){
}
}
}
static class myThread2 extends Thread{
public void run() {
while (true){
System.out.println("Ура");
try {
Thread.sleep(500);
} catch (InterruptedException e) {
System.out.println("InterruptedException");
}
}
}
}
static class myThread3 extends Thread{
@Override
public void run() {
try {
while (true) {
System.out.println("Ура");
Thread.sleep(500);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
static class myThread4 extends Thread implements Message{
public void run() {
while (!this.isInterrupted()){
}
}
public void showWarning() {
this.interrupt();
}
}
static class myThread5 extends Thread {
public void run() {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
while (true){
try {
String N = bufferedReader.readLine();
if (N.equals("N")){
break;
} else {
sum = sum + Integer.parseInt(N);
}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println(sum);
}
}
public static void main(String[] args) {
}
}