Skip to content

Instantly share code, notes, and snippets.

@cypressious
Last active May 25, 2016 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cypressious/28dbbc1a7adcfe844f134232c5a8e8f3 to your computer and use it in GitHub Desktop.
Save cypressious/28dbbc1a7adcfe844f134232c5a8e8f3 to your computer and use it in GitHub Desktop.
val mutex = Semaphore(0)
val source = Observable.interval(200, TimeUnit.MILLISECONDS).take(10)
val delayed = source.delayUntil(3L)
println("${System.currentTimeMillis()}: start")
delayed.subscribe(
{ println("${System.currentTimeMillis()}: $it") },
{ println("Failed with $it") },
{ mutex.release() }
)
mutex.acquire()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment