public class UpdateMebinfoThread implements Runnable{
private int beginnum= 0;// 开始行数
private int endnum= 0;// 读取记录数
public UpdateMebinfoThread(int beginnum, int endnum)
{
super();
this.beginnum= beginnum;
this.endnum= endnum;
}
@Override
public void run() {
System.out.println(Thread.currentThread().getName() + "===beginnum:"+beginnum);
System.out.println(Thread.currentThread().getName() + "====endnum:"+endnum);
}
}
public static void main(String[] args) throws InterruptedException { ExecutorService threadPool= Executors.newScheduledThreadPool(10);// 初始化线程池 int count= 100000; //总数 int threadCount=10000; //初始值 int beginnum= 0; int endnum= 0; while (count>0) { endnum= count> threadCount? threadCount: count; UpdateMebinfoThread thread= new UpdateMebinfoThread(beginnum, endnum); threadPool.execute(thread); beginnum= beginnum+ endnum; count= count- endnum; } threadPool.shutdown(); }