4 回答
TA贡献64条经验 获得超115个赞
关键在
System.out.println(String.format("thread: %s , tiketnum = %d do some thing",Thread.currentThread().getName(),ticket--));
如果将ticket--移出来,改写成
System.out.println(String.format("thread: %s , tiketnum = %d do some thing",Thread.currentThread().getName(),ticket));
ticket--;
输出就正常了
thread: th0 , tiketnum = 10 do some thing
thread: th0 , tiketnum = 9 do some thing
thread: th0 , tiketnum = 8 do some thing
thread: th0 , tiketnum = 7 do some thing
thread: th0 , tiketnum = 6 do some thing
thread: th0 , tiketnum = 5 do some thing
thread: th0 , tiketnum = 4 do some thing
thread: th0 , tiketnum = 3 do some thing
thread: th0 , tiketnum = 2 do some thing
thread: th0 , tiketnum = 1 do some thing
thread: th0 , tiketnum = 0 do some thing
thread: th0 , tiketnum = -1 do some thing
添加回答
举报