HomeAbout MeContact Me

Java concurrency explained with a few examples

By Emanuele Papa
Published in Development
May 06, 2017
1 min read
Java concurrency explained with a few examples

Sometimes we write very high level code, sometimes we don’t. I want to put here a link to a simple project which shows how to deal with concurrency in Java with a few examples.

The project is available on Github here

Goal of the project is to retrieve the details and the balance of a player and show them at the same time: until you have collected both of them you have to wait before showing the user the information.

There are two different packages: in the first, Futures and Callables are being used, in the other, Threads/Runnables and a CountDownLatch are.

Futures and Callables are the best option when you need to run a task which has a return value. I also made it in a different way using Threads/Runnables, a CountDownLatch and some listeners but these classes are usually used when you have tasks which won’t return any value.

Use the two Main classes to run the examples. Have fun!


Previous Article
AWS S3 custom policy
Emanuele Papa

Emanuele Papa

Android Developer


Smart Home

Related Posts

Flutter Padding widgets generator with Paddinger
May 16, 2021
1 min

Quick Links

HomeAbout MeContact MeRSS Feed

Social Media