Skip to content

Commit 8c028a1

Browse files
author
Dominik Liebler
committed
Merge branch 'step3'
2 parents 2511323 + 227e189 commit 8c028a1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ This is the example from my [blog post with the same title](https://domnikl.gith
55
- [Step 0](https://github.com/domnikl/kotlin-coroutines-and-javafx-threads/blob/step0/src/main/kotlin/Main.kt)
66
- [Step 1](https://github.com/domnikl/kotlin-coroutines-and-javafx-threads/blob/step1/src/main/kotlin/Main.kt)
77
- [Step 2](https://github.com/domnikl/kotlin-coroutines-and-javafx-threads/blob/step2/src/main/kotlin/Main.kt)
8+
- [Step 3](https://github.com/domnikl/kotlin-coroutines-and-javafx-threads/blob/step3/src/main/kotlin/Main.kt)

src/main/kotlin/Main.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import kotlinx.coroutines.*
88
import kotlinx.coroutines.javafx.JavaFx
99
import kotlin.coroutines.CoroutineContext
1010

11-
class MillisElapsedCounter(private val observer: Observer) {
11+
class MillisElapsedCounter(private val observer: Observer) : CoroutineScope {
12+
override val coroutineContext: CoroutineContext
13+
get() = Dispatchers.Default
14+
1215
fun start() {
13-
GlobalScope.launch(Dispatchers.Default) {
16+
launch {
1417
var millisElapsed = 0
1518

1619
while (true) {

0 commit comments

Comments
 (0)