Netflix/RxJava — pull request #557 by akarnokd (2013-12-04 10:54:18+00:00)
Title: ObserveOn: Moved queue into a per-observer instance.

I don't fully understand why the original didn't work properly. My guess is either the shared queue between observers or a race condition on the recursiveScheduler field. My implementation seems to work correctly with the test case in #551

```java
public class ObserveOnTest {
static class PrintObserver implements Observer {
private final String prefix;
public PrintObserver(String prefix) {
this.prefix = prefix;
}
void printPrefix() {
System.out.print(prefix);
System.out.print(": ");
}
@Override
public void onNext(T args) {
synchronized (PrintObserver.class) {
printPrefix();
System.out.println(args);
}
}

@Override
public void onError(Throwable e) {
synchronized (PrintObserver.class) {
printPrefix();
System.out.println(e);
}
}

@Override
public void onCompleted() {
synchronized (PrintObserver.class) {
printPrefix();
System.out.println("done");
}
}

}
public static void main(String[] args) throws Exception {
Observable o = Observable.from(1, 2, 3);
Observable o2 = o.observeOn(Schedulers.threadPoolForComputation());

System.out.println("Subscribe A");
o2.subscribe(new PrintObserver<>("a"));
System.out.println("Subscribe B");
o2.subscribe(new PrintObserver<>("b"));
System.out.println("Waiting");
Thread.sleep(1000);
System.out.println("Done");
}
}
```