@@ -22,7 +22,7 @@ r.run(); // Execute on main thread
2222new Thread (r). start();
2323new Thread (r). start();
2424```
25- Output
25+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SingleThreadedExample.java )
2626```
2727onNext(1) on 1
2828Received 1 on 1
@@ -66,7 +66,7 @@ Observable.create(o -> {
6666
6767System . out. println(" Finished main: " + Thread . currentThread(). getId());
6868```
69- Output
69+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java )
7070```
7171Main: 1
7272Created on 1
@@ -77,7 +77,7 @@ Finished main: 1
7777
7878We see here that, not only is everything executed on the same thread, it is actually sequential: ` subscribe ` does not unblock until it has completed subscribing to (and thus creating) the observable, which includes executing the body of ` create ` 's lambda parameter. The calls to ` onNext ` within that lambda execute the entire chain of operators, all the way to the ` println ` . Effectively, subscribing on a ` create ` d observable is blocking.
7979
80- If you uncomment ` .subscribeOn(Schedulers.newThread()) ` , the output now is
80+ If you uncomment ` .subscribeOn(Schedulers.newThread()) ` , the [ Output ] ( /tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java ) now is
8181```
8282Main: 1
8383Finished main: 1
@@ -100,7 +100,7 @@ Observable.interval(100, TimeUnit.MILLISECONDS)
100100
101101System . out. println(" Finished main: " + Thread . currentThread(). getId());
102102```
103- Output
103+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java )
104104```
105105Main: 1
106106Finished main: 1
@@ -124,7 +124,7 @@ Observable.create(o -> {
124124 .subscribe(i - >
125125 System . out. println(" Received " + i + " on " + Thread . currentThread(). getId()));
126126```
127- Output
127+ [ Output] ( /tests/java/itrx/chapter4/scheduling/ObserveOnExample.java )
128128```
129129Created on 1
130130Received 1 on 13
@@ -147,7 +147,7 @@ Observable.create(o -> {
147147 System . out. println(" After " + i + " on " + Thread . currentThread(). getId()))
148148 .subscribe();
149149```
150- Output
150+ [ Output] ( /tests/java/itrx/chapter4/scheduling/ObserveOnExample.java )
151151```
152152Created on 1
153153Before 1 on 1
@@ -183,7 +183,7 @@ source
183183 .unsubscribeOn(Schedulers . newThread())
184184 .subscribe(System . out:: println);
185185```
186- Output
186+ [ Output] ( /tests/java/itrx/chapter4/scheduling/UnsubscribeOnExample.java )
187187```
188188Subscribed on 1
189189Producing on 1
@@ -256,7 +256,7 @@ worker.schedule(
256256 () - > System . out. println(System . currentTimeMillis()- start),
257257 5 , TimeUnit . SECONDS );
258258```
259- Output
259+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SchedulerExample.java )
260260```
2612615033
2622625035
@@ -282,7 +282,7 @@ worker.schedule(
282282 () - > System . out. println(System . currentTimeMillis()- start),
283283 5 , TimeUnit . SECONDS );
284284```
285- Output
285+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SchedulerExample.java )
286286```
2872875032
288288```
@@ -304,7 +304,7 @@ worker.schedule(() -> {
304304Thread . sleep(500 );
305305worker. unsubscribe();
306306```
307- Output
307+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SchedulerExample.java )
308308```
309309Action interrupted
310310```
@@ -326,7 +326,7 @@ worker.schedule(() -> {
326326 System . out. println(" End" );
327327});
328328```
329- Output
329+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SchedulersExample.java )
330330```
331331Start
332332Inner
@@ -346,7 +346,7 @@ worker.schedule(() -> {
346346 System.out.println("End");
347347});
348348```
349- Output
349+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SchedulersExample.java )
350350```
351351Start
352352End
@@ -378,7 +378,7 @@ worker.schedule(() -> {
378378Thread . sleep(500 );
379379worker. schedule(() - > printThread(" Again" ));
380380```
381- Output
381+ [ Output] ( /tests/java/itrx/chapter4/scheduling/SchedulersExample.java )
382382```
383383Main on 1
384384Start on 11
0 commit comments