Java -- CountDownLatch、CyclicBarrier、Semaphore

  1. CoutDownLatch and CyclicBarrier are both used to realize mutual waiting between multiple threads, but they have different concerns. CountDownLatch is mainly used for threads to wait for the execution of other sub-thread tasks before executing the next business logic unit, while CyclicBarrier is mainly used for a group of threads to wait for each other to reach a certain state, and then execute the next business logic unit at the same time . In addition, CountDownLatch is not reusable, while CyclicBarrier is reusable
  2. Semaphore is similar to the lock function in Java, mainly used to control concurrent access to resources

Guess you like

Origin blog.csdn.net/weixin_44556968/article/details/110393560