Skip to content

Commit e3b1152

Browse files
committed
CommonPool deprecated
1 parent c315ce5 commit e3b1152

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

‎core-kotlin/src/test/kotlin/com/baeldung/kotlin/CoroutinesUnitTest.kt‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class CoroutinesTest {
6060

6161
//when
6262
runBlocking {
63-
val promise = launch(CommonPool) { expensiveComputation(res) }
63+
val promise = launch(Dispatchers.Default) { expensiveComputation(res) }
6464
res.add("Hello,")
6565
promise.join()
6666
}
@@ -84,7 +84,7 @@ class CoroutinesTest {
8484

8585
//when
8686
val jobs = List(numberOfCoroutines) {
87-
launch(CommonPool) {
87+
launch(Dispatchers.Default) {
8888
delay(1L)
8989
counter.incrementAndGet()
9090
}
@@ -100,7 +100,7 @@ class CoroutinesTest {
100100
fun givenCancellableJob_whenRequestForCancel_thenShouldQuit() {
101101
runBlocking<Unit> {
102102
//given
103-
val job = launch(CommonPool) {
103+
val job = launch(Dispatchers.Default) {
104104
while (isActive) {
105105
//println("is working")
106106
}
@@ -134,8 +134,8 @@ class CoroutinesTest {
134134
val delay = 1000L
135135
val time = measureTimeMillis {
136136
//given
137-
val one = async(CommonPool) { someExpensiveComputation(delay) }
138-
val two = async(CommonPool) { someExpensiveComputation(delay) }
137+
val one = async(Dispatchers.Default) { someExpensiveComputation(delay) }
138+
val two = async(Dispatchers.Default) { someExpensiveComputation(delay) }
139139

140140
//when
141141
runBlocking {
@@ -155,8 +155,8 @@ class CoroutinesTest {
155155
val delay = 1000L
156156
val time = measureTimeMillis {
157157
//given
158-
val one = async(CommonPool, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
159-
val two = async(CommonPool, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
158+
val one = async(Dispatchers.Default, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
159+
val two = async(Dispatchers.Default, CoroutineStart.LAZY) { someExpensiveComputation(delay) }
160160

161161
//when
162162
runBlocking {

‎core-kotlin/src/test/kotlin/com/baeldung/thread/CoroutineUnitTest.kt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class CoroutineUnitTest {
4646
return@async "${Thread.currentThread()} has run."
4747
}
4848

49-
5049
val result = deferred.await()
5150
println(result)
5251
}

0 commit comments

Comments
 (0)