All Projects → mechero → completable-future-example

mechero / completable-future-example

Licence: other
Example project comparing Java's CompletableFuture and Future implementations

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to completable-future-example

Java Trader
Java Future trader CTP FEMAS XTP
Stars: ✭ 54 (+68.75%)
Mutual labels:  future
Asyncninja
A complete set of primitives for concurrency and reactive programming on Swift
Stars: ✭ 146 (+356.25%)
Mutual labels:  future
Asyncfuture
Use QFuture like a Promise object
Stars: ✭ 193 (+503.13%)
Mutual labels:  future
Wp Missed Schedule
Find only missed schedule posts, every 15 minutes, and republish correctly 10 items each session. The Original plugin (only this) no longer available on WordPress.org for explicit author request! Compatible with WP 2.1+ to 4.9+ and 5.0-beta3 (100.000+ installs 300.000+ downloads 2016-04-13) Please: do not install unauthorized malware cloned forked!
Stars: ✭ 69 (+115.63%)
Mutual labels:  future
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (+346.88%)
Mutual labels:  future
Future.apply
🚀 R package: future.apply - Apply Function to Elements in Parallel using Futures
Stars: ✭ 159 (+396.88%)
Mutual labels:  future
Vngo
golang version of vn.py
Stars: ✭ 25 (-21.87%)
Mutual labels:  future
paneer-tikka-masala
A Code Kata using a cooking recipe to make an Indian curry, Paneer Tikka Masala (grilled and marinated cottage cheese in a tomato and cream gravy).
Stars: ✭ 20 (-37.5%)
Mutual labels:  completablefuture
Qtpromise
Promises/A+ implementation for Qt/C++
Stars: ✭ 137 (+328.13%)
Mutual labels:  future
Fluture
🦋 Fantasy Land compliant (monadic) alternative to Promises
Stars: ✭ 2,249 (+6928.13%)
Mutual labels:  future
Btctrading
Time Series Forecast with Bitcoin value, to detect upward/down trends with Machine Learning Algorithms
Stars: ✭ 99 (+209.38%)
Mutual labels:  future
Amazingquant
基于Event-driven的量化交易解决方案
Stars: ✭ 128 (+300%)
Mutual labels:  future
Java Concurrency Examples
Java Concurrency/Multithreading Tutorial with Examples for Dummies
Stars: ✭ 173 (+440.63%)
Mutual labels:  future
Gollback
Go asynchronous simple function utilities, for managing execution of closures and callbacks
Stars: ✭ 55 (+71.88%)
Mutual labels:  future
Dsl.scala
A framework to create embedded Domain-Specific Languages in Scala
Stars: ✭ 220 (+587.5%)
Mutual labels:  future
Portable concurrency
Portable implementation of future/promise API in C++
Stars: ✭ 48 (+50%)
Mutual labels:  future
Promise
Promise / Future library for Go
Stars: ✭ 149 (+365.63%)
Mutual labels:  future
future.scala
Stack-safe asynchronous programming
Stars: ✭ 38 (+18.75%)
Mutual labels:  future
Radwimps
君の then-then-then 世は Promise で Future
Stars: ✭ 229 (+615.63%)
Mutual labels:  future
Fushare
A utility for fundamentals data of China commodity futures
Stars: ✭ 176 (+450%)
Mutual labels:  future

CompletableFuture, Future and Streams

This project uses a sample use case to compare Java's CompletableFuture with plain Future and other approaches like plain Java and the Stream API.

There is a story behind this code to make it more fun and, at the same time, to give a goal to the sample code so it's easier to compare. Welcome to the Java Bank Robbery with CompletableFutures, Futures and Streams.

The Java Bank Robbery

Blog

The comparison between these approaches, and a good introduction to CompletableFuture is available at The Practical Developer Site. I recommend you to read that guide to follow the codebase.

Code

The code is split into three main parts:

  • The main application class App, which runs the different code alternatives and shows the result.
  • The objects used to represent this story: Actions, Loot and Thief.
  • The alternatives used to execute the story:
    • SingleThreadOpenSafeLock contains two approaches, both single-threaded: plain, imperative Java and Stream API based.
    • FutureOpenSafeLock implements the plan using Java Futures, also in imperative-ish way.
    • CompletableFutureOpenSafeLock uses a few important methods of the CompletableFuture API to demonstrate how powerful it is to solve composed, multi-threaded problems.

Remember that the conclusions of the comparison are also included in the guide so, check it out now!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].