package com.wgtgt.utils; public class MutilThreadUtil { public static void main(String[] args) { int fileLength=55; int countThread=5; int[][]nums=split(fileLength,countThread); print(nums); System.out.println("fileLength="+fileLength); System.out.println("countThread="+countThread); } public static int[][]split(int fileLength,int countThread){ int everyLength; everyLength=fileLength/countThread; int shengyu=fileLength-everyLength*countThread; int[][]result=new int[countThread][2]; int cursor=0; for (int i = 0; i < countThread; i++) { result[i][0]=cursor; cursor+=everyLength-1; if(shengyu-->0){ cursor+=1; } result[i][1]=cursor; cursor++; } return result; } public static void print(int[][]nums){ for (int i = 0; i < nums.length; i++) { System.out.println(i+"\t"+nums[i][0]+"\t"+nums[i][1]+"\t"+(nums[i][1]-nums[i][0]+1)); } } }

duxing LV2
2022年6月10日
mylzdy LV12
2022年5月21日
顾北城 LV12
2022年5月8日
zhenghongixin4065 LV9
2021年1月25日
3063686836 LV4
2020年7月16日
liuyilin9608 LV15
2020年5月17日
黄丹丹 LV2
2020年1月17日
wangyan110 LV2
2019年11月7日
初秋若寒 LV10
2019年10月15日
倪卟懂 LV18
2019年7月23日

暂无贡献等级
snowing_for LV9
2024年11月25日
liu1221 LV1
2024年4月20日
Small CN LV7
2023年1月12日
heqian LV17
2022年10月17日
我们都是小怪兽 LV3
2022年9月6日
MoonSight LV1
2022年7月1日
xuexizhuanyong23 LV16
2022年6月29日
lingqianjue LV3
2022年6月14日
duxing LV2
2022年6月10日