{"id":15039389,"url":"https://github.com/kotlin/kotlinx.coroutines","last_synced_at":"2025-09-09T21:14:16.834Z","repository":{"id":37406892,"uuid":"61722736","full_name":"Kotlin/kotlinx.coroutines","owner":"Kotlin","description":"Library support for Kotlin coroutines ","archived":false,"fork":false,"pushed_at":"2025-04-30T10:20:04.000Z","size":36167,"stargazers_count":13355,"open_issues_count":314,"forks_count":1886,"subscribers_count":290,"default_branch":"master","last_synced_at":"2025-05-05T16:05:24.808Z","etag":null,"topics":["async","coroutines","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kotlin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2016-06-22T13:49:21.000Z","updated_at":"2025-05-05T06:23:19.000Z","dependencies_parsed_at":"2023-12-20T12:42:15.526Z","dependency_job_id":"974ab7a4-3ec5-4493-a3ee-013f976987d2","html_url":"https://github.com/Kotlin/kotlinx.coroutines","commit_stats":{"total_commits":2818,"total_committers":323,"mean_commits":8.724458204334365,"dds":0.656139105748758,"last_synced_commit":"6c6df2b850382887462eeaf51f21f58bd982491d"},"previous_names":[],"tags_count":105,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx.coroutines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx.coroutines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx.coroutines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kotlin%2Fkotlinx.coroutines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kotlin","download_url":"https://codeload.github.com/Kotlin/kotlinx.coroutines/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253354489,"owners_count":21895436,"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":["async","coroutines","kotlin"],"created_at":"2024-09-24T20:42:38.781Z","updated_at":"2025-09-09T21:14:16.558Z","avatar_url":"https://github.com/Kotlin.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kotlinx.coroutines \n\n[![Kotlin Stable](https://kotl.in/badges/stable.svg)](https://kotlinlang.org/docs/components-stability.html)\n[![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)\n[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)\n[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.10.2)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.10.2)\n[![Kotlin](https://img.shields.io/badge/kotlin-2.1.0-blue.svg?logo=kotlin)](http://kotlinlang.org)\n[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://kotlinlang.org/api/kotlinx.coroutines/)\n[![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/)\n\nLibrary support for Kotlin coroutines with [multiplatform](#multiplatform) support.\nThis is a companion version for the Kotlin `2.1.0` release.\n\n```kotlin\nsuspend fun main() = coroutineScope {\n    launch { \n       delay(1000)\n       println(\"Kotlin Coroutines World!\") \n    }\n    println(\"Hello\")\n}\n```\n\n\u003e Play with coroutines online [here](https://pl.kotl.in/lPYtYEtD5)\n\n## Modules\n\n* [core](kotlinx-coroutines-core/README.md) \u0026mdash; common coroutines across all platforms:\n  * [launch] and [async] coroutine builders returning [Job] and [Deferred] light-weight futures with cancellation support;\n  * [Dispatchers] object with [Main][Dispatchers.Main] dispatcher for Android/Swing/JavaFx (which require the corresponding artifacts in runtime) and Darwin (included out of the box), and [Default][Dispatchers.Default] dispatcher for background coroutines;\n  * [delay] and [yield] top-level suspending functions;\n  * [Flow] \u0026mdash; cold asynchronous stream with [flow][_flow] builder and comprehensive operator set ([filter], [map], etc);\n  * [Channel], [Mutex], and [Semaphore] communication and synchronization primitives;\n  * [coroutineScope][_coroutineScope], [supervisorScope][_supervisorScope], [withContext], and [withTimeout] scope builders;\n  * [MainScope()] for Android and UI applications;\n  * [SupervisorJob()] and [CoroutineExceptionHandler] for supervision of coroutines hierarchies;\n  * [select] expression support and more.\n* [core/jvm](kotlinx-coroutines-core/jvm/) \u0026mdash; additional core features available on Kotlin/JVM:\n  * [Dispatchers.IO] dispatcher for blocking coroutines;\n  * [Executor.asCoroutineDispatcher][asCoroutineDispatcher] extension, custom thread pools, and more;\n  * Integrations with `CompletableFuture` and JVM-specific extensions.\n* [core/js](kotlinx-coroutines-core/js/) \u0026mdash; additional core features available on Kotlin/JS:\n  * Integration with `Promise` via [Promise.await] and [promise] builder;\n  * Integration with `Window` via [Window.asCoroutineDispatcher], etc.\n* [test](kotlinx-coroutines-test/README.md) \u0026mdash; test utilities for coroutines:\n  * [Dispatchers.setMain] to override [Dispatchers.Main] in tests;\n  * [runTest] and [TestScope] to test suspending functions and coroutines.\n* [debug](kotlinx-coroutines-debug/README.md) \u0026mdash; debug utilities for coroutines:\n  * [DebugProbes] API to probe, keep track of, print and dump active coroutines;\n  * [CoroutinesTimeout] test rule to automatically dump coroutines on test timeout.\n  * Automatic integration with [BlockHound](https://github.com/reactor/BlockHound).\n* [reactive](reactive/README.md) \u0026mdash; modules that provide builders and iteration support for various reactive streams libraries:\n  * Reactive Streams ([Publisher.collect], [Publisher.awaitSingle], [kotlinx.coroutines.reactive.publish], etc), \n  * Flow (JDK 9) (the same interface as for Reactive Streams),\n  * RxJava 2.x ([rxFlowable], [rxSingle], etc), and\n  * RxJava 3.x ([rxFlowable], [rxSingle], etc), and\n  * Project Reactor ([flux], [mono], etc).\n* [ui](ui/README.md) \u0026mdash; modules that provide the [Main][Dispatchers.Main] dispatcher for various single-threaded UI libraries:\n  * Android, JavaFX, and Swing.\n* [integration](integration/README.md) \u0026mdash; modules that provide integration with various asynchronous callback- and future-based libraries:\n  * Guava [ListenableFuture.await], and Google Play Services [Task.await];\n  * SLF4J MDC integration via [MDCContext].\n\n## Documentation\n\n* Presentations and videos:\n  * [Kotlin Coroutines in Practice](https://www.youtube.com/watch?v=a3agLJQ6vt8) (Roman Elizarov at KotlinConf 2018, [slides](https://www.slideshare.net/elizarov/kotlin-coroutines-in-practice-kotlinconf-2018))\n  * [Deep Dive into Coroutines](https://www.youtube.com/watch?v=YrrUCSi72E8) (Roman Elizarov at KotlinConf 2017, [slides](https://www.slideshare.net/elizarov/deep-dive-into-coroutines-on-jvm-kotlinconf-2017))\n  * [History of Structured Concurrency in Coroutines](https://www.youtube.com/watch?v=Mj5P47F6nJg) (Roman Elizarov at Hydra 2019, [slides](https://speakerdeck.com/elizarov/structured-concurrency))\n* Guides and manuals: \n  * [Guide to kotlinx.coroutines by example](https://kotlinlang.org/docs/coroutines-guide.html) (**read it first**)\n  * [Guide to UI programming with coroutines](ui/coroutines-guide-ui.md)\n  * [Debugging capabilities in kotlinx.coroutines](docs/topics/debugging.md)\n* [Compatibility policy and experimental annotations](docs/topics/compatibility.md)\n* [Change log for kotlinx.coroutines](CHANGES.md)\n* [Coroutines design document (KEEP)](https://github.com/Kotlin/KEEP/blob/master/proposals/coroutines.md)\n* [Full kotlinx.coroutines API reference](https://kotlinlang.org/api/kotlinx.coroutines/)\n \n## Using in your projects\n\n### Maven\n\nAdd dependencies (you can also add other modules that you need):\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.jetbrains.kotlinx\u003c/groupId\u003e\n    \u003cartifactId\u003ekotlinx-coroutines-core\u003c/artifactId\u003e\n    \u003cversion\u003e1.10.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nAnd make sure that you use the latest Kotlin version:\n\n```xml\n\u003cproperties\u003e\n    \u003ckotlin.version\u003e2.1.0\u003c/kotlin.version\u003e\n\u003c/properties\u003e\n```\n\n### Gradle\n\nAdd dependencies (you can also add other modules that you need):\n\n```kotlin\ndependencies {\n    implementation(\"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2\")\n}\n```\n\nAnd make sure that you use the latest Kotlin version:\n\n```kotlin\nplugins {\n    // For build.gradle.kts (Kotlin DSL)\n    kotlin(\"jvm\") version \"2.1.0\"\n    \n    // For build.gradle (Groovy DSL)\n    id \"org.jetbrains.kotlin.jvm\" version \"2.1.0\"\n}\n```\n\nMake sure that you have `mavenCentral()` in the list of repositories:\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n```\n\n### Android\n\nAdd [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)\nmodule as a dependency when using `kotlinx.coroutines` on Android:\n\n```kotlin\nimplementation(\"org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2\")\n```\n\nThis gives you access to the Android [Dispatchers.Main]\ncoroutine dispatcher and also makes sure that in case of a crashed coroutine with an unhandled exception that\nthis exception is logged before crashing the Android application, similarly to the way uncaught exceptions in\nthreads are handled by the Android runtime.\n\n#### R8 and ProGuard\n\nR8 and ProGuard rules are bundled into the [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android) module.\nFor more details see [\"Optimization\" section for Android](ui/kotlinx-coroutines-android/README.md#optimization).\n\n#### Avoiding including the debug infrastructure in the resulting APK\n\nThe `kotlinx-coroutines-core` artifact contains a resource file that is not required for the coroutines to operate\nnormally and is only used by the debugger. To exclude it at no loss of functionality, add the following snippet to the\n`android` block in your Gradle file for the application subproject:\n\n```kotlin\npackagingOptions {\n    resources.excludes += \"DebugProbesKt.bin\"\n}\n```\n\n### Multiplatform\n\nCore modules of `kotlinx.coroutines` are also available for \n[Kotlin/JS](https://kotlinlang.org/docs/reference/js-overview.html) and [Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html).\n\nIn common code that should get compiled for different platforms, you can add a dependency to `kotlinx-coroutines-core` right to the `commonMain` source set:\n\n```kotlin\ncommonMain {\n    dependencies {\n        implementation(\"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2\")\n    }\n}\n```\n\nPlatform-specific dependencies are recommended to be used only for non-multiplatform projects that are compiled only for target platform.\n\n#### JS\n\nKotlin/JS version of `kotlinx.coroutines` is published as \n[`kotlinx-coroutines-core-js`](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.10.2)\n(follow the link to get the dependency declaration snippet).\n\n#### Native\n\nKotlin/Native version of `kotlinx.coroutines` is published as \n[`kotlinx-coroutines-core-$platform`](https://central.sonatype.com/search?q=kotlinx-coroutines-core\u0026namespace=org.jetbrains.kotlinx) where `$platform` is \nthe target Kotlin/Native platform. \nTargets are provided in accordance with [official K/N target support](https://kotlinlang.org/docs/native-target-support.html).\n## Building and Contributing\n\nSee [Contributing Guidelines](CONTRIBUTING.md).\n\n\u003c!--- MODULE kotlinx-coroutines-core --\u003e\n\u003c!--- INDEX kotlinx.coroutines --\u003e\n\n[launch]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html\n[async]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html\n[Job]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/index.html\n[Deferred]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/index.html\n[Dispatchers]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/index.html\n[Dispatchers.Main]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-main.html\n[Dispatchers.Default]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html\n[delay]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/delay.html\n[yield]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/yield.html\n[_coroutineScope]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html\n[_supervisorScope]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/supervisor-scope.html\n[withContext]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/with-context.html\n[withTimeout]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/with-timeout.html\n[MainScope()]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-main-scope.html\n[SupervisorJob()]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-supervisor-job.html\n[CoroutineExceptionHandler]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-exception-handler/index.html\n[Dispatchers.IO]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-i-o.html\n[asCoroutineDispatcher]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/as-coroutine-dispatcher.html\n[Promise.await]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/await.html\n[promise]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/[js]promise.html\n[Window.asCoroutineDispatcher]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/as-coroutine-dispatcher.html\n\n\u003c!--- INDEX kotlinx.coroutines.flow --\u003e\n\n[Flow]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html\n[_flow]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/flow.html\n[filter]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/filter.html\n[map]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/map.html\n\n\u003c!--- INDEX kotlinx.coroutines.channels --\u003e\n\n[Channel]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-channel/index.html\n\n\u003c!--- INDEX kotlinx.coroutines.selects --\u003e\n\n[select]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.selects/select.html\n\n\u003c!--- INDEX kotlinx.coroutines.sync --\u003e\n\n[Mutex]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/index.html\n[Semaphore]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-semaphore/index.html\n\n\u003c!--- MODULE kotlinx-coroutines-test --\u003e\n\u003c!--- INDEX kotlinx.coroutines.test --\u003e\n\n[Dispatchers.setMain]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/set-main.html\n[runTest]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/run-test.html\n[TestScope]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-scope/index.html\n\n\u003c!--- MODULE kotlinx-coroutines-debug --\u003e\n\u003c!--- INDEX kotlinx.coroutines.debug --\u003e\n\n[DebugProbes]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-debug/kotlinx.coroutines.debug/-debug-probes/index.html\n\n\u003c!--- INDEX kotlinx.coroutines.debug.junit4 --\u003e\n\n[CoroutinesTimeout]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-debug/kotlinx.coroutines.debug.junit4/-coroutines-timeout/index.html\n\n\u003c!--- MODULE kotlinx-coroutines-slf4j --\u003e\n\u003c!--- INDEX kotlinx.coroutines.slf4j --\u003e\n\n[MDCContext]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-slf4j/kotlinx.coroutines.slf4j/-m-d-c-context/index.html\n\n\u003c!--- MODULE kotlinx-coroutines-jdk8 --\u003e\n\u003c!--- INDEX kotlinx.coroutines.future --\u003e\n\u003c!--- MODULE kotlinx-coroutines-guava --\u003e\n\u003c!--- INDEX kotlinx.coroutines.guava --\u003e\n\n[ListenableFuture.await]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-guava/kotlinx.coroutines.guava/await.html\n\n\u003c!--- MODULE kotlinx-coroutines-play-services --\u003e\n\u003c!--- INDEX kotlinx.coroutines.tasks --\u003e\n\n[Task.await]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/await.html\n\n\u003c!--- MODULE kotlinx-coroutines-reactive --\u003e\n\u003c!--- INDEX kotlinx.coroutines.reactive --\u003e\n\n[Publisher.collect]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/collect.html\n[Publisher.awaitSingle]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/await-single.html\n[kotlinx.coroutines.reactive.publish]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-reactive/kotlinx.coroutines.reactive/publish.html\n\n\u003c!--- MODULE kotlinx-coroutines-rx2 --\u003e\n\u003c!--- INDEX kotlinx.coroutines.rx2 --\u003e\n\n[rxFlowable]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-flowable.html\n[rxSingle]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-rx2/kotlinx.coroutines.rx2/rx-single.html\n\n\u003c!--- MODULE kotlinx-coroutines-rx2 --\u003e\n\u003c!--- INDEX kotlinx.coroutines.rx2 --\u003e\n\u003c!--- MODULE kotlinx-coroutines-reactor --\u003e\n\u003c!--- INDEX kotlinx.coroutines.reactor --\u003e\n\n[flux]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/flux.html\n[mono]: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-reactor/kotlinx.coroutines.reactor/mono.html\n\n\u003c!--- END --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin%2Fkotlinx.coroutines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkotlin%2Fkotlinx.coroutines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkotlin%2Fkotlinx.coroutines/lists"}