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();
}
}
}
并发demo
最新推荐文章于 2023-11-06 17:45:16 发布