Java Concurrency Programming: Countdownlatch, Cyclicbarrier, and Semaphore (summary)

Source: Internet
Author: User
Tags semaphore

  

Here is a summary of the three auxiliary classes mentioned above:

1) Countdownlatch and Cyclicbarrier are capable of waiting between threads, except that they focus differently:

Countdownlatch is typically used when a thread a waits for several other threads to finish executing a task before it executes;

And Cyclicbarrier is generally used for a group of threads to wait for each other to a certain state, then this group of threads execute concurrently;

In addition, Countdownlatch cannot be reused, and cyclicbarrier can be reused.

2) Semaphore is actually a bit like a lock, which is typically used to control access to a group of resources.

Reference: 1, Java concurrency Programming: Countdownlatch, Cyclicbarrier, and semaphore

Java Concurrency Programming: Countdownlatch, Cyclicbarrier, and Semaphore (summary)

Related Article

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.