Vignesh's Dumpster 🗑️

Home

❯

01 Work

❯

01 Kotlin

❯

Semaphore

Semaphore

Aug 03, 20251 min read

  • kotlin

https://www.linkedin.com/feed/update/urn:li:activity:7305672195647635461?utm_source=share&utm_medium=member_desktop&rcm=ACoAACuB3psBh2PUIfwLTN82nVsB3uHQfrfJgFw

Example

private val semaphore = Semaphore(permits = 3)
 
suspend fun download() {
	if (semaphore.availablePermits == 0) 
	semaphore.withPermit {
		// write your logic here
		// permit acquired, start downloading
	}
}

Graph View

Backlinks

  • 01-Kotlin

Created with Quartz v4.5.2 © 2025

  • GitHub
  • Discord Community