{"id":15651013,"url":"https://github.com/mechero/completable-future-example","last_synced_at":"2025-04-30T18:21:58.064Z","repository":{"id":90103148,"uuid":"121962463","full_name":"mechero/completable-future-example","owner":"mechero","description":"Example project comparing Java's CompletableFuture and Future implementations","archived":false,"fork":false,"pushed_at":"2018-02-24T09:27:26.000Z","size":102,"stargazers_count":34,"open_issues_count":0,"forks_count":22,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T18:43:55.997Z","etag":null,"topics":["completablefuture","future","java","thepracticaldeveloper"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mechero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-18T15:11:14.000Z","updated_at":"2023-11-06T07:00:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"7769a088-2a4c-4b49-8f35-4b20d08b66fa","html_url":"https://github.com/mechero/completable-future-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fcompletable-future-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fcompletable-future-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fcompletable-future-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mechero%2Fcompletable-future-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mechero","download_url":"https://codeload.github.com/mechero/completable-future-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758311,"owners_count":21639011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["completablefuture","future","java","thepracticaldeveloper"],"created_at":"2024-10-03T12:36:37.558Z","updated_at":"2025-04-30T18:21:58.033Z","avatar_url":"https://github.com/mechero.png","language":"Java","readme":"# CompletableFuture, Future and Streams\n\nThis project uses a sample use case to compare Java's `CompletableFuture` with plain `Future` and other approaches like plain Java and the Stream API.\n\nThere 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.\n\n![The Java Bank Robbery](img/guide-to-completable-future.png)\n\n## Blog\n\nThe comparison between these approaches, and a good introduction to `CompletableFuture` is available at [The Practical Developer Site](https://thepracticaldeveloper.com/?p=1027). I recommend you to read that guide to follow the codebase.\n\n## Code\n\nThe code is split into three main parts:\n\n* The main application class `App`, which runs the different code alternatives and shows the result.\n* The `objects` used to represent this story: `Actions`, `Loot` and `Thief`.\n* The alternatives used to execute the story:\n  * `SingleThreadOpenSafeLock` contains two approaches, both single-threaded: plain, imperative Java and Stream API based.\n  * `FutureOpenSafeLock` implements the plan using Java Futures, also in imperative-ish way.\n  * `CompletableFutureOpenSafeLock` uses a few important methods of the `CompletableFuture` API to demonstrate how powerful it is to solve composed, multi-threaded problems.\n\nRemember that the conclusions of the comparison are also included in the guide so, [check it out now!](https://thepracticaldeveloper.com/?p=1027)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechero%2Fcompletable-future-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmechero%2Fcompletable-future-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmechero%2Fcompletable-future-example/lists"}