package www.xwcms.net.struts.action; public class Diao implements Runnable{ private int num = 10; public void run() { for(int i=0; i<5; i++){ //使用同步代码块 synchronized (this) { try { Thread.currentThread().sleep(1000); System.out.println("22"); //Thread.currentThread().sleep(); } catch (Exception e) { e.printStackTrace(); } if(this.num>0){ System.out.println(Thread.currentThread().getName() + "得到: " + this.num--); } } } } public static void main(String[] args) { Diao diaos = new Diao(); new Thread(diaos,"线程一").start(); //线程一 new Thread(diaos,"线程 二").start(); //线程二 new Thread(diaos,"线程三").start(); //线程三 } }

13856120525 LV1
2023年2月17日
yymmdm LV6
2022年8月30日
sl0018 LV13
2022年6月13日
Mayoubin2001 LV21
2022年3月26日
zhjwgs LV15
2022年2月22日
17798830 LV14
2022年1月25日
czr2233 LV9
2021年9月14日
huaua7676 LV30
2021年7月28日
明123456 LV11
2021年5月27日
dongzhan LV12
2021年3月3日

uni-code_0123 LV1
2023年11月29日
微信网友_6755417394941952
2023年11月28日
暂无贡献等级
13856120525 LV1
2023年2月17日
慵懒的小橘猫 LV11
2022年11月16日
8战魂5无双8 LV43
2022年9月13日
yymmdm LV6
2022年8月30日
sl0018 LV13
2022年6月12日
1635162218 LV9
2022年5月31日
qwer765 LV1
2022年5月11日
qwerasdf123456 LV2
2022年4月24日