java多线程并发例子

public static void main(String[] args) {	
for(Thread t:getThreads()){
t.start();
}
}

public static Thread[] getThreads(){
Thread[] thread = new Thread[10];
for(int i=0;i<10;i++){
final Integer num = new Integer(i);
thread[i] = new Thread(new Runnable(){
public void run() {
int j=5;
while(j-->0){
System.out.println("this is thread"+num);
}
}
});
}
return thread;
}
posted @ 2016-08-30 13:53  你明哥  阅读(462)  评论(0编辑  收藏  举报