Cyclicbarrier in Java concurrent programming for a set of threads to wait for each other

Source: Internet
Author: User

The cyclicbarrier in the Concurrent Concurrency Library package introduced by Java 5 is a synchronous helper class that allows a set of threads to wait until they reach a common barrier point (common barrier points). In programs that involve a set of fixed-size threads, these threads have to wait for each other, and cyclicbarrier is useful at this time. Because the barrier can be reused after releasing the waiting thread, it is called a cyclic barrier. Cyclicbarrier supports an optional Runnable command that runs only once at each barrier point after the last thread in a set of threads arrives (but before releasing all threads). This barrier operation is useful if you update the shared state before continuing with all participating threads. For example: In a certain demand, a large task, often need to allocate a lot of sub-tasks to execute, only when all the subtasks are completed to perform the main task, this time, you can choose Cyclicbarrier.

Cyclicbarrier in Java concurrent programming for a set of threads to wait for each other

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.