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) 評論(0)  編輯  收藏 所屬分類: j2se


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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 内黄县| 重庆市| 三亚市| 台北县| 平南县| 扬州市| 卓尼县| 乌兰浩特市| 板桥市| 宁武县| 南安市| 遂平县| 曲松县| 托克逊县| 辽阳县| 白城市| 齐齐哈尔市| 县级市| 无棣县| 平潭县| 余姚市| 磐石市| 民勤县| 宁明县| 建阳市| 杂多县| 咸丰县| 康保县| 澄迈县| 彭水| 茶陵县| 大化| 烟台市| 勐海县| 本溪市| 金华市| 遂平县| 岳阳市| 中方县| 万盛区| 永顺县|