What's wrong the output is correct
package com.codegym.task.task16.task1614;
import java.util.ArrayList;
import java.util.List;
/*
Countdown
*/
public class Solution {
public static volatile List<String> list = new ArrayList<>(5);
static {
for (int i = 0; i < 5; i++) {
list.add("Line " + i);
}
}
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(new Countdown(3), "Countdown");
t.start();
}
//Countdown class implements Runnable
public static class Countdown implements Runnable {
private int countFrom;
public Countdown(int countFrom) {
this.countFrom = countFrom;
}
public void run() {
try {
while (countFrom > 0) {
printCountdown();
}
} catch (InterruptedException e) {
}
}
public void printCountdown() throws InterruptedException {
//write your code here
Thread.sleep(500);
for(int i = this.countFrom -1; i >= 0; i--){
System.out.println(list.get(i));
this.countFrom = i;
}
}
}
}