public static void main(String[] args) {
int[] arr = {1,4,7,3,8,9,2,6,5};
//创建指定长度的线程数组
SThread[] threads = new SThread[arr.length];
//指定每个线程数组的值
for (int i = 0; i < threads.length; i++) {
threads[i] = new SThread(arr[i]);
}
//开启每个线程
for (int i = 0; i < threads.length; i++) {
threads[i].start();
}
}
static class SThread extends Thread{
int s = 0;
public SThread(int s){
this.s = s;
}
public void run(){
try {
sleep(s); //睡眠指定的时间
} catch (InterruptedException e) {
e.printStackTrace();
}
//输出该数
System.out.println(s);
}
}