public class Solution {
public static volatile List<Thread> list = new ArrayList<>(5);
public static void main(String[] args) {
//write your code here
Thread spThread1 = new SpecialThread();
Thread spThread2 = new SpecialThread();
Thread spThread3 = new SpecialThread();
Thread spThread4 = new SpecialThread();
Thread spThread5 = new SpecialThread();
Thread thread1 = new Thread(spThread1);
Thread thread2 = new Thread(spThread2);
Thread thread3 = new Thread(spThread3);
Thread thread4 = new Thread(spThread4);
Thread thread5 = new Thread(spThread5);
list.add(thread1);
list.add(thread2);
list.add(thread3);
list.add(thread4);
list.add(thread5);
for (Thread thread : list)
{
thread.start();
}
}
public static class SpecialThread extends Thread implements Runnable {
public void run() {
System.out.println("This is the run method inside SpecialThread");
}
}
}
package com.codegym.task.task16.task1603;
import java.util.ArrayList;
import java.util.List;
/*
A list and some threads
*/
public class Solution {
public static volatile List<Thread> list = new ArrayList<>(5);
public static void main(String[] args) {
//write your code here
Thread spThread1 = new SpecialThread();
Thread spThread2 = new SpecialThread();
Thread spThread3 = new SpecialThread();
Thread spThread4 = new SpecialThread();
Thread spThread5 = new SpecialThread();
Thread thread1 = new Thread(spThread1);
Thread thread2 = new Thread(spThread2);
Thread thread3 = new Thread(spThread3);
Thread thread4 = new Thread(spThread4);
Thread thread5 = new Thread(spThread5);
list.add(thread1);
list.add(thread2);
list.add(thread3);
list.add(thread4);
list.add(thread5);
for (Thread thread : list)
{
thread.start();
}
}
public static class SpecialThread extends Thread implements Runnable {
public void run() {
System.out.println("This is the run method inside SpecialThread");
}
}
}