沈真成是被选召的孩子
2016-01-03 12:35
我出现了楼上的情况后改了代码: public void run() {
while(number>0){
System.out.println(Thread.currentThread().getName()+"卖出一张票,还剩"+(--number));
}
} 但最后输出结果仍然没变 什么鬼 输出:
商店2卖出一张票,还剩4
商店3卖出一张票,还剩3
商店1卖出一张票,还剩4
商店3卖出一张票,还剩1
商店2卖出一张票,还剩2
商店1卖出一张票,还剩0
你没有加同步块吧?synchroized
细说多线程之Thread VS Runnable
55316 学习 · 73 问题
相似问题