barrybao

          2006年4月17日 #

          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 @ 2006-04-17 23:44 以苦為樂 閱讀(349) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 乃东县| 古交市| 乌拉特后旗| 乌鲁木齐市| 东乡族自治县| 房产| 社旗县| 石柱| 临猗县| 襄城县| 都江堰市| 临泉县| 虹口区| 崇文区| 玉屏| 定日县| 远安县| 灵石县| 包头市| 贺兰县| 永德县| 漯河市| 宁化县| 盱眙县| 九寨沟县| 清丰县| 马鞍山市| 泸水县| 邯郸县| 永靖县| 海盐县| 仁寿县| 唐海县| 全椒县| 隆安县| 酒泉市| 丰台区| 鲜城| 汽车| 平谷区| 葵青区|