barrybao

          Thread.wait

          Today, I tried to wirte some code to test thread. Use a Schedular to controll thread's running. For thread: public class ControllerThread extends Thread { public void run() { ... Schedular.waitForOthers(this); ... } } In Schedular public class Schedular { public static synchronized void waitForOthers(ControllerThread thread) throws InterruptedException { waitingThreadNum++; // waitingThreadNum is a counter. if (waitingThreadNum != threads.size()) { System.out.println("Thread:" + thread.getName() + " is going to wait"); wait(); // thread.wait() is useless here } else { waitingThreadNum = 0; System.out.println("All threads will run"); notifyAll(); } } } Is there anybody know why thread.wait cannot work in Schedular?

          posted on 2006-04-17 23:44 以苦為樂 閱讀(349) 評(píng)論(0)  編輯  收藏 所屬分類: j2se


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 临武县| 宁河县| 泸水县| 陵川县| 调兵山市| 宁明县| 聊城市| 乌兰浩特市| 平顺县| 新乡市| 赫章县| 镇宁| 淮安市| 贵州省| 个旧市| 蓬溪县| 富宁县| 天峨县| 石柱| 嘉黎县| 个旧市| 九龙县| 宝山区| 黑河市| 舟曲县| 同德县| 永年县| 海兴县| 江北区| 许昌市| 舟曲县| 抚远县| 双桥区| 阿合奇县| 丹棱县| 吴忠市| 基隆市| 五峰| 全椒县| 浮梁县| 龙岩市|