Skip to content

volkodavs/java-concurrency

Repository files navigation

Java Concurrency

overview

Synchronizers

syn

Sempaphore

Example

Imagine we have to park with a five parking space. When the parking space is full, newly arrived car can park after car from parking space will leave the parking.

sempaphore

Documentation

CountDownLatch

Example

Imagine we have car racing before we can begin, following conditions should meet:

  • All five cars should be on start line
  • The command "Prepare!" should be done
  • The command "Ready!" should be done
  • The command "Go!" should be done

It's essential that all five cars start at the same time.

countdownlatch

Documentation

CyclicBarrier

Example

Imagine we have a ferry that transport cars. The boat can transport only three vehicles at the same time, and we can carry cars just after on a ferry we had three vehicles.

cyclicbarrier

Documentation

Exchanger

Example

Imagine we have two tracks. The first one is going from A to D, and the second one is going from B to C. The roads AD and BC is crossing at E. From A and B we should dispatch envelopes to C and D, to do that, two tracks should meet at E and exchange envelopes.

exchanger

Documentation

Phaser

Example

Imagine we have five bus stops. At the first four people can wait for a bus. The bus starts a journey and stops on all the bus stops, after fifth bus stop it's going to bus depot. We should:

  • pick the people
  • drop off the people

phaser

Documentation

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages