Skip to content

Commit 14a15f4

Browse files
committed
resolve conflict
2 parents 05867f3 + 1bc5c7c commit 14a15f4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

core-kotlin-modules/core-kotlin-collections-6/src/test/kotlin/com/baeldung/parallelOperationsCollections/ParallelOperationCollectionsUnitTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,23 @@ class ParallelOperationCollectionsUnitTest {
142142
observable.assertResultsTrue()
143143
}
144144

145+
@Test
146+
fun `using RxKotlin but still use 1 thread`() { // ObservableKt.kt.class from io.reactivex.rxkotlin
147+
logger.info("Using RxKotlin 1 thread")
148+
val startTime = Instant.now()
149+
150+
val observable = people.toObservable()
151+
.subscribeOn(Schedulers.io())
152+
.flatMap { Observable.just(it) } // Without using the maxConcurrency parameter, so it only uses 1 thread.
153+
.doOnNext { person -> person.setAdult() }
154+
.filter { it.age > 15 }.toList()
155+
.map { it.sortedBy { person -> person.age } }.blockingGet()
156+
157+
startTime.printTotalTime()
158+
159+
observable.assertResultsTrue()
160+
}
161+
145162
@Test
146163
fun `using parallelStream()`() {
147164
logger.info("Using Stream API")

0 commit comments

Comments
 (0)