Skip to content

Instantly share code, notes, and snippets.

@Diolor
Last active December 1, 2018 01:47
Show Gist options
  • Save Diolor/339643ef078081ebfe76fc923b0d124c to your computer and use it in GitHub Desktop.
Save Diolor/339643ef078081ebfe76fc923b0d124c to your computer and use it in GitHub Desktop.
fun printCurrentThread(tag: String) = println("$tag: ${Thread.currentThread().name.substringBefore("-")}")
fun main(args: Array<String>) {
printCurrentThread("main thread name")
val subject = BehaviorSubject.create(Unit)
subject
.subscribeOn(Schedulers.computation())
.subscribe {
printCurrentThread("subscribe onNext")
}
Thread.sleep(100L)
Completable.complete()
.observeOn(Schedulers.io())
.subscribe {
subject.onNext(Unit)
}
Thread.sleep(100L)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment