Routine vs Coroutine - RxJava Kotlin

PHOTO EMBED

Wed Apr 07 2021 10:21:17 GMT+0000 (Coordinated Universal Time)

Saved by @GoodRequest.

fun main() {
    println("main starts")
    val disposables = CompositeDisposable()
    disposables.addAll(
        Completable.fromAction {
            routine(1, 500)
        }.subscribeOn(Schedulers.newThread()).subscribe(),
        Completable.fromAction {
            routine(2, 300)
        }.subscribeOn(Schedulers.newThread()).subscribe()
    )
    Thread.sleep(600)
    println("main ends")
    disposables.dispose()
}
content_copyCOPY