Last active
January 2, 2016 13:39
-
-
Save zsxwing/8311369 to your computer and use it in GitHub Desktop.
Asnyc exmaple
This file contains hidden or 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
import rx.lang.scala.Observable._ | |
import rx.lang.scala.JavaConversions._ | |
import rx.lang.scala.ImplicitFunctionConversions._ | |
import rx.util.async.Async | |
import java.util.concurrent.Executors | |
import rx.schedulers.Schedulers | |
object Test extends App { | |
val executor = Executors.newFixedThreadPool(10) | |
val scheduler = Schedulers.executor(executor) | |
val o = Async.start({ | |
// some blocking actions | |
Thread.sleep(2000) | |
1 | |
}, scheduler) | |
println(o.toBlockingObservable().single()) | |
executor.shutdown() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment