A barrier is a Java synchronizer that allows a group of threads (known as parties) to reach a common barrier point. Basically, a group of threads waits for each other to meet at the barrier. It is like a bunch of friends who decide on a meeting point, and when all of them get this point, they go farther together. They won't leave the meeting point until all of them have arrived or until they feel they've been waiting too long.
This synchronizer works well for problems that rely on a task that can be divided into subtasks. Each subtask runs in a different thread and waits for the rest of the threads. When all the threads complete, they combine their results in a single result.
This following diagram shows an example of a barrier ...