-
-
Save PatilShreyas/5f9b8d0c9a1890bc52f82bd190e62b8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
semaphore.acquire() | |
// Releases a permit, returning it into this semaphore. | |
// Resumes the first suspending acquirer if there is one at the point of invocation | |
semaphore.release() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment