Asynchronous Kotlin framework for building microservices, web applications and HTTP APIs, developed by JetBrains.
Kotlin/kotlinx.coroutines
Kotlin library providing coroutine builders, dispatchers, Flow, channels and structured concurrency primitives for asynchronous code.
- Stars
- 13,823
- Forks
- 1,951
- Open issues
- 348
- Last commit
- 2 days ago
What is it?
kotlinx.coroutines is the official Kotlin library that adds coroutine support on top of the language's suspending functions. It supplies builders such as launch and async that return cancellable Job and Deferred handles, along with delay, yield, and scope builders like coroutineScope and withTimeout for organizing work into structured hierarchies.
Beyond the core, the library includes Flow for cold asynchronous streams with a broad set of operators, Channel, Mutex and Semaphore for communication and synchronization, and select for waiting on multiple suspending sources. Dispatchers cover background work, and platform-specific modules add a Main dispatcher for Android, JavaFX and Swing, an IO dispatcher and CompletableFuture integration on the JVM, and Promise support on Kotlin/JS and Wasm.
The project also provides kotlinx-coroutines-test for running suspending code in tests with runTest and a virtual-time TestScope, a debug module with DebugProbes for dumping active coroutines, and reactive and integration modules for Reactive Streams, RxJava, Project Reactor, Guava and Google Play Services. Core modules target JVM, JS and Native.
Key features
- 01Launch and async builders returning cancellable Job and Deferred handles.
- 02Flow cold streams with a comprehensive operator set.
- 03Channel, Mutex and Semaphore for communication and synchronization.
- 04Dispatchers for background, IO and Android/Swing/JavaFX main threads.
- 05Test utilities with runTest and TestScope, plus a DebugProbes module for inspecting coroutines.
Use cases
- Writing asynchronous and concurrent logic in Kotlin/JVM server or desktop applications.
- Building Android apps that need main-thread coroutine dispatching and crash logging.
- Sharing coroutine-based business logic across Kotlin Multiplatform targets.
- Testing suspending functions with virtual time.
Quick start
- 1
Add the kotlinx-coroutines-core dependency to your Gradle build
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0") - 2
Make sure mavenCentral() is in your repositories
mavenCentral() - 3
Use the latest Kotlin version in your plugins block
kotlin("jvm") version "2.2.20"
Topics
FAQ
- What is kotlinx.coroutines?
- Kotlin library providing coroutine builders, dispatchers, Flow, channels and structured concurrency primitives for asynchronous code. kotlinx.coroutines is the official Kotlin library that adds coroutine support on top of the language's suspending functions. It supplies builders such as launch and async that return cancellable Job and Deferred handles, along with delay, yield, and scope builders like coroutineScope and withTimeout for organizing work into structured hierarchies.
- Is kotlinx.coroutines free to use? What license does it have?
- kotlinx.coroutines is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is kotlinx.coroutines still maintained?
- Actively maintained. The last commit to kotlinx.coroutines was on Oct 23, 2026.
- What can I use kotlinx.coroutines for?
- Writing asynchronous and concurrent logic in Kotlin/JVM server or desktop applications. Building Android apps that need main-thread coroutine dispatching and crash logging. Sharing coroutine-based business logic across Kotlin Multiplatform targets. Testing suspending functions with virtual time.
- How do I install kotlinx.coroutines?
- Add the kotlinx-coroutines-core dependency to your Gradle build: implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0") Make sure mavenCentral() is in your repositories: mavenCentral() Use the latest Kotlin version in your plugins block: kotlin("jvm") version "2.2.20"
- Where can I get kotlinx.coroutines?
- The source code and installation instructions are on GitHub: https://github.com/Kotlin/kotlinx.coroutines
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Java VM implementation of Reactive Extensions for composing asynchronous and event-based programs with observable sequences.
A PHP extension providing an event-driven networking engine and coroutine runtime for building long-running TCP, UDP, HTTP, and WebSocket services.
An actor framework for Rust that runs typed message-passing actors on the Tokio runtime, with supervision support.
A Ruby gem offering concurrency primitives such as futures, promises, thread pools, agents, atoms, thread-safe collections and synchronization classes.
A free, open-source collection of Rust exercises and examples, organized by chapter with runnable, editable code and solutions.