rx java - about Schedulers.newThread() -


public static void main(string[] args) {     list<integer> list = arrays.aslist(1,2,3,4,5,6,7);     observable.from(list)             .map(new func1<integer, string>() {                 @override                 public string call(integer integer) {                     return   string.format("%d ",integer);                 }             }).subscribeon(schedulers.newthread())             .observeon(schedulers.newthread())             .subscribe(new action1<string>() {                 @override                 public void call(string s) {                     system.out.print(s);                 }             }); } 

here's test when use rxjava. print nothing.i don't know why.anybody can give me help? thanks.

rxjava standard schedulers daemon threads. when main() method exits, jvm quits , daemon threads stopped.

place thread.sleep(5000) @ end of main() method , you'll see output printed. alternatively, apply .toblocking() before .subscribe() call.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -