How can I add a sleep(1000) to this code?
I've tried but I can't get it to work.
(This program is supposed to be an infinite loop)
public class ExtendedThread extends Thread {
public ExtendedThread(String name) throws InterruptedException {
super(name);
}
public void run() {
for (int i = 1; i >= 1; i++) {
System.out.println("Thread " + getName() + i);
}
}
public static void main (String[] args)throws InterruptedException {
int numThreads = Integer.parseInt(args[0]);
ExtendedThread[] threads = new ExtendedThread[numThreads];
for (int i = 1; i <= (numThreads + 1); i++) {
threads[i] = new ExtendedThread (i + " - Count ");
threads[i].start();
}
}
}