V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
maxwellwenjie894
V2EX  ›  问与答

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

  •  
  •   maxwellwenjie894 · Aug 17, 2021 · 1083 views
    This topic created in 1715 days ago, the information mentioned may be changed or developed.

    最近在读《 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 循环永远不会停止了,好心人帮忙解答下

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4466 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 00:09 · PVG 08:09 · LAX 17:09 · JFK 20:09
    ♥ Do have faith in what you're doing.