Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Barrier break down example

I am reading the book Java Concurrency in Practice where it says,

CyclicBarrier allows a fixed number of parties to rendezvous repeatedly at a barrier point and is useful in parallel iterative algorithms that break down a problem into a fixed number of independent subproblems.

Can someone give an example of how it breaks down a problem into multiple independent subproblems?

like image 522
peter Avatar asked Aug 08 '26 21:08

peter


1 Answers

You have to break the problem down into multiple independent subproblems yourself.

Barriers ensure that each party completes the first subproblem before any of them start on the second subproblem. This ensures that all of the data from the first subproblem is available before the second subproblem is started.

A CyclicBarrier specifically is used when the same barrier is needed again and again when each step is effectively identical. For example, this could occur when doing any sort of multithreaded reality simulation which is done in steps. The CyclicBarrier would ensure that each thread has completed a given step before all threads will begin the next step.

like image 167
Erick Robertson Avatar answered Aug 10 '26 11:08

Erick Robertson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!