package com.sleep;
public class Main {
public static void main(String[] args) {
int[] arr = {1, 9, 2, 8, 8, 3, 6, 4, 5, 7};
for (int i1 : arr) {
new SleepThread(i1).start();
}
}
}
class SleepThread extends Thread {
private int number;
SleepThread(int number) {
this.number = number;
}
@Override
public void run() {
try {
Thread.sleep(number * 500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(number + "");
}
}
这里*500毫秒,方便看过程,如果数大一点,嗯…