并发demo

package Thread;

class ThreadMode{
	public Thread getThread() {
		Thread thread=new Thread(new Runnable() {
			public void run() {
				for(int i = 0;i < 1024 ; i++){
                    System.out.println("out:"+i);
                }
			}
		});
		return thread;
	}
}
public class 并发demo {
	//5个线程并发执行到1024
	private static final int THREADNUM = 5;//线程数量  
	public static void main(String[] args) {
		int threadmax=THREADNUM;
		for(int i=0;i<threadmax;i++){
			ThreadMode thread=new ThreadMode();
			thread.getThread().start();
		}
	}
}

猜你喜欢

转载自blog.csdn.net/wenyimutouren/article/details/82223022
今日推荐