67,515
社区成员
发帖
与我相关
我的任务
分享
//任务批次ID(每次任务的ID)
private static volatile int smNo =0; //序列号,循环进位,满了之后再从0开始计位
//获取任务批次ID
public static synchronized int getsnMo() {
if(smNo==3)
{
smNo=0;
}
int a=smNo;
++smNo;
return a;
}
public static void main(String[] args) {
int a = 0;
for (int y = 0; y <= 20; y++) {
for (int i = 0; i <= 3; i++) {
System.out.println("i = " + i);
System.out.println("a = " + (i + 4 * a));
if (i == 3) {
a++;
}
}
}
}