Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include runBlocking() in context and dispatchers tutorial code #3674

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/topics/coroutine-context-and-dispatchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Try the following example:
```kotlin
import kotlinx.coroutines.*

fun main() = runBlocking<Unit> {
//sampleStart
fun main() = runBlocking<Unit> {
launch { // context of the parent, main runBlocking coroutine
println("main runBlocking : I'm working in thread ${Thread.currentThread().name}")
}
Expand All @@ -37,9 +37,9 @@ fun main() = runBlocking<Unit> {
}
launch(newSingleThreadContext("MyOwnThread")) { // will get its own new thread
println("newSingleThreadContext: I'm working in thread ${Thread.currentThread().name}")
}
//sampleEnd
}
}
//sampleEnd
```
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

Expand Down Expand Up @@ -88,8 +88,8 @@ this thread with predictable FIFO scheduling.
```kotlin
import kotlinx.coroutines.*

fun main() = runBlocking<Unit> {
//sampleStart
fun main() = runBlocking<Unit> {
launch(Dispatchers.Unconfined) { // not confined -- will work with main thread
println("Unconfined : I'm working in thread ${Thread.currentThread().name}")
delay(500)
Expand All @@ -99,9 +99,9 @@ fun main() = runBlocking<Unit> {
println("main runBlocking: I'm working in thread ${Thread.currentThread().name}")
delay(1000)
println("main runBlocking: After delay in thread ${Thread.currentThread().name}")
}
//sampleEnd
}
}
//sampleEnd
```
{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

Expand Down