Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// This is example to explain the API for semaphore
fun main() {
// Creates semaphore with 10 permits
val semaphore = Semaphore(permits = 10)
// Acquires a permit from this semaphore, suspending until one is available.
// All suspending acquirers are processed in first-in-first-out (FIFO) order
// Releases a permit, returning it into this semaphore.
// Resumes the first suspending acquirer if there is one at the point of invocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment