From 1047da59c6a4f434d493a798bd147d3dd481c5a9 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 2 Aug 2017 11:09:38 +0300 Subject: [PATCH 1/2] Fixed incorrect result output Fixed incorrect result output for exampleSubscribeOn() --- tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java b/tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java index ebae61d..b2ea853 100644 --- a/tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java +++ b/tests/java/itrx/chapter4/scheduling/SubscribeOnExample.java @@ -74,10 +74,10 @@ public void exampleSubscribeOn() { System.out.println("Finished main: " + Thread.currentThread().getId()); // Main: 1 - // Created on 1 + // Created on 11 // Received 1 on 11 // Received 2 on 11 - // Finished main: 11 + // Finished main: 1 } public void exampleIntervalThread() { From 135d65f7c657233128fdfb0eb4bf09081a9d2db4 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 2 Aug 2017 11:56:22 +0300 Subject: [PATCH 2/2] Fixed result output Fixed result output for method exampleRefcount(), also little bit improved. --- .../hotandcold/ConnectableObservableExample.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/java/itrx/chapter3/hotandcold/ConnectableObservableExample.java b/tests/java/itrx/chapter3/hotandcold/ConnectableObservableExample.java index 37212b4..4c522eb 100644 --- a/tests/java/itrx/chapter3/hotandcold/ConnectableObservableExample.java +++ b/tests/java/itrx/chapter3/hotandcold/ConnectableObservableExample.java @@ -114,7 +114,7 @@ public void exampleRefcount() throws InterruptedException { Thread.sleep(500); Subscription s2 = cold.subscribe(i -> System.out.println("Second: " + i)); Thread.sleep(500); - System.out.println("Unsubscribe first"); + System.out.println("Unsubscribe second"); s2.unsubscribe(); Thread.sleep(500); System.out.println("Unsubscribe first"); @@ -123,6 +123,9 @@ public void exampleRefcount() throws InterruptedException { System.out.println("First connection again"); Thread.sleep(500); s1 = cold.subscribe(i -> System.out.println("First: " + i)); + Thread.sleep(900); + System.out.println("Unsubscribe first again"); + s1.unsubscribe(); // First: 0 // First: 1 @@ -130,8 +133,9 @@ public void exampleRefcount() throws InterruptedException { // Second: 2 // First: 3 // Second: 3 - // Unsubscribe first // First: 4 + // Second: 4 + // Unsubscribe second // First: 5 // First: 6 // Unsubscribe first @@ -140,7 +144,7 @@ public void exampleRefcount() throws InterruptedException { // First: 1 // First: 2 // First: 3 - // First: 4 + // Unsubscribe first again }