ExecutorService touchWorker = Executors.newFixedThreadPool(4, new ThreadFactoryBuilder().setNameFormat("touch-send-worker-%d").build());
int size = orgList.size();
if(size > 100)
{
int batch = size % 100 == 0 ? size / 100 : size / 100 + 1;
for(int j = 0; j < batch; j++)
{
int end = (j + 1) * 100;
if(end > size)
{
end = size;
}
List <OrganizeStructure> subList = orgList.subList(j * 100, end);
touchWorker.execute( () -> this.sleepOrg(subList));
}
touchWorker.shutdown();
while(true)
{
if(touchWorker.isTerminated())
{
//全部线程执行结束
break;
}
}
}
else
{
this.sleepOrg(orgList);
}
网友评论