Skip to content

Commit a740aa2

Browse files
testNotificationDelay - Attempt at determinism
1 parent d4cf435 commit a740aa2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

rxjava-core/src/test/java/rx/observers/SerializedObserverTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ public void runConcurrencyTest() {
272272
*/
273273
@Test
274274
public void testNotificationDelay() throws InterruptedException {
275-
ExecutorService tp = Executors.newFixedThreadPool(2);
275+
ExecutorService tp1 = Executors.newFixedThreadPool(1);
276+
ExecutorService tp2 = Executors.newFixedThreadPool(1);
276277
try {
277278
int n = 10;
278279
for (int i = 0; i < n; i++) {
@@ -306,8 +307,8 @@ public void onNext(String t) {
306307
});
307308
Observer<String> o = serializedObserver(to);
308309

309-
Future<?> f1 = tp.submit(new OnNextThread(o, 1, onNextCount, running));
310-
Future<?> f2 = tp.submit(new OnNextThread(o, 1, onNextCount, running));
310+
Future<?> f1 = tp1.submit(new OnNextThread(o, 1, onNextCount, running));
311+
Future<?> f2 = tp2.submit(new OnNextThread(o, 1, onNextCount, running));
311312

312313
running.await(); // let one of the OnNextThread actually run before proceeding
313314

@@ -333,7 +334,8 @@ public void onNext(String t) {
333334
System.out.println(to.getOnNextEvents());
334335
}
335336
} finally {
336-
tp.shutdown();
337+
tp1.shutdown();
338+
tp2.shutdown();
337339
}
338340
}
339341

0 commit comments

Comments
 (0)