Am I on the right track? Do you have to make the Threads static if you put them in a static block. Thanks in advance.
package com.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 {
threads.add(new Thread1());
threads.add(new Thread2());
threads.add(new Thread3());
threads.add(new Thread4());
threads.add(new Thread5());
}
public static void main(String[] args) {
}
public static class Thread1 extends Thread {
public void run() {
}
}
public static class Thread2 extends Thread {
public void run() {
}
}
public static class Thread3 extends Thread {
public void run() {
try {
Thread3.sleep(500);
System.out.println("Hurray");
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static class Thread4 extends Thread implements Message{
public void showWarning() {
while (true) {
if (!this.isAlive())
{
this.interrupt();
}
}
}
public void run() {
}
}
public static class Thread5 extends Thread {
public void run() {
}
}
}