{"id":23208992,"url":"https://github.com/yegor256/together","last_synced_at":"2026-01-07T12:18:37.672Z","repository":{"id":268599904,"uuid":"904850130","full_name":"yegor256/together","owner":"yegor256","description":"Executes Java lambda in multiple threads and collects their results (useful for testing for thread-safety)","archived":false,"fork":false,"pushed_at":"2025-08-31T11:26:07.000Z","size":127,"stargazers_count":16,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-31T13:18:08.950Z","etag":null,"topics":["concurrency","java","java-8","java-li","testing","thread-safety","threads"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yegor256.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-17T17:06:37.000Z","updated_at":"2025-05-19T10:07:02.000Z","dependencies_parsed_at":"2024-12-17T19:35:22.951Z","dependency_job_id":"eaecb828-8854-45ae-a35c-66c1803aa57f","html_url":"https://github.com/yegor256/together","commit_stats":null,"previous_names":["yegor256/together"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/yegor256/together","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ftogether","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ftogether/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ftogether/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ftogether/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/together/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Ftogether/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274010099,"owners_count":25206763,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["concurrency","java","java-8","java-li","testing","thread-safety","threads"],"created_at":"2024-12-18T18:13:33.916Z","updated_at":"2026-01-07T12:18:37.666Z","avatar_url":"https://github.com/yegor256.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Runs Java Lambda in Many Threads\n\n[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/together)](https://www.rultor.com/p/yegor256/together)\n[![We recommend IntelliJ IDEA](https://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)\n\n[![mvn](https://github.com/yegor256/together/actions/workflows/mvn.yml/badge.svg)](https://github.com/yegor256/together/actions/workflows/mvn.yml)\n[![PDD status](https://www.0pdd.com/svg?name=yegor256/together)](https://www.0pdd.com/p?name=yegor256/together)\n[![Maven Central](https://img.shields.io/maven-central/v/com.yegor256/together.svg)](https://maven-badges.herokuapp.com/maven-central/com.yegor256/together)\n[![Javadoc](https://www.javadoc.io/badge/com.yegor256/together.svg)](https://www.javadoc.io/doc/com.yegor256/together)\n[![codecov](https://codecov.io/gh/yegor256/together/branch/master/graph/badge.svg)](https://codecov.io/gh/yegor256/together)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/together)](https://hitsofcode.com/view/github/yegor256/together)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/together/blob/master/LICENSE.txt)\n\nWith this small Java library you can test your objects\nfor [thread safety] by doing some manipulations with them\nin multiple parallel threads. You may read this blog post,\nin order to understand the motivation for this type of\ntesting better: [How I Test My Java Classes for Thread-Safety][blog].\n\nBy the way, there are similar libraries for Java, but they are\neither more complex or less tests-oriented, for example\n[lincheck],\n[ConcurrentUnit](https://github.com/jhalterman/concurrentunit),\n[`RunsInThreads`][RunsInThreads] from [cactoos-matchers],\nor\n[`Threads`][Threads] from [Cactoos](https://github.com/yegor256/cactoos).\n\nFirst, you add this library to your `pom.xml` in [Maven]:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.yegor256\u003c/groupId\u003e\n  \u003cartifactId\u003etogether\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThen, you use it like this, in your [JUnit5] test\n(with [Hamcrest]):\n\n```java\nimport org.hamcrest.MatcherAssert;\nimport org.hamcrest.Matchers;\nimport org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.io.TempDir;\nimport com.yegor256.Together;\n\nclass FooTest {\n  @Test\n  void worksAsExpected() {\n    MatcherAssert.assertThat(\n      \"processes all lambdas successfully\",\n      new Together\u003c\u003e(\n        thread -\u003e {\n          // Do the job and use \"thread\" as a number\n          // of the thread currently running (they are all unique).\n          return true;\n        }\n      ),\n      Matchers.not(Matchers.hasItem(Matchers.is(false)))\n    );\n  }\n}\n```\n\nHere, the `Together` class runs the \"job\" in multiple threads\nand makes sure that all of them return `true`. If at least\none of them returns `false`, the test fails. If at least one of the\nthreads throws an exception, the test also fails.\n\n`Together` guarantees that all threads start exactly simultaneously,\nthus simulating [race condition] as much as it's possible. This is exactly\nwhat you need for your tests: making sure your object under test\nexperiences troubles that are very similar to what it might experience\nin real life.\n\nFor even better/stronger testing, you can use\n[`@RepeatedTest`][RepeatedTest].\n\n## How to Contribute\n\nFork repository, make changes, send us a\n[pull request](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nWe will review your changes and apply them to the `master` branch shortly,\nprovided they don't violate our quality standards. To avoid frustration,\nbefore sending us your pull request please run full Maven build:\n\n```bash\nmvn clean install -Pqulice\n```\n\nYou will need [Maven] 3.3+ and Java 11+.\n\n[blog]: https://www.yegor256.com/2018/03/27/how-to-test-thread-safety.html\n[JUnit5]: https://junit.org/junit5/\n[Hamcrest]: http://hamcrest.org\n[Maven]: https://maven.apache.org\n[race condition]: https://en.wikipedia.org/wiki/Race_condition\n[thread safety]: https://en.wikipedia.org/wiki/Thread_safety\n[RunsInThreads]: https://github.com/llorllale/cactoos-matchers/blob/master/src/main/java/org/llorllale/cactoos/matchers/RunsInThreads.java\n[cactoos-matchers]: https://github.com/llorllale/cactoos-matchers\n[Threads]: https://github.com/yegor256/cactoos/blob/master/src/main/java/org/cactoos/experimental/Threads.java\n[lincheck]: https://github.com/JetBrains/lincheck\n[RepeatedTest]: https://junit.org/junit5/docs/5.0.1/api/org/junit/jupiter/api/RepeatedTest.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Ftogether","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Ftogether","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Ftogether/lists"}