V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
maxwellwenjie894
V2EX  ›  问与答

求助 JCIP: CyclicBarrier 时对书上的例子有一些疑惑

  •  
  •   maxwellwenjie894 · 2021-08-17 00:35:58 +08:00 · 527 次点击
    这是一个创建于 954 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近在读《 Java Concurrency in Practice 》,读到 CyclicBarrier 时对书上的例子有一些疑惑,大家能帮忙解答下吗?[https://jcip.net/listings/CellularAutomata.java]

    在 5.15 Coordinating computation in a cellular automaton with CyclicBarrier.中

        public void start() {
            for (int i = 0; i < workers.length; i++)
                new Thread(workers[i]).start();
            mainBoard.waitForConvergence();
        }
        
        while (!board.hasConverged())。。。
    

    这里我理解 mainBoard.waitForConvergence();是一个判断 while (!board.hasConverged())终止的条件;如果书里这样写的话,mainBoard.waitForConvergence();运行的时间不确定啊,如果在判断之前,是不是 while 循环永远不会停止了,好心人帮忙解答下

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2627 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 15:50 · PVG 23:50 · LAX 08:50 · JFK 11:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.