---
title: "Comment by Marek Langiewicz on \"Coroutines racing! Why, and how.\" | Hashnode"
description: "Same example with some result (for single thread dispatcher): suspend fun awaitTrigger () : T { var t: T? = null coroutineScope { val scope = this launch { t ="
url: "https://hashnode.com/posts/coroutines-racing-why-and-how/618a2953f991b025366df06f/comment/61925833fd3a1a5a01a8897b"
---

[Discussion](https://hashnode.com/posts/coroutines-racing-why-and-how/618a2953f991b025366df06f)

Comment [Coroutines racing! Why, and how.](https://hashnode.com/posts/coroutines-racing-why-and-how/618a2953f991b025366df06f)

[Marek Langiewicz](https://hashnode.com/@Langara)

[Nov 15, 2021](https://hashnode.com/posts/coroutines-racing-why-and-how/618a2953f991b025366df06f/comment/61925833fd3a1a5a01a8897b)

Same example with some result (for single thread dispatcher):

```
suspend fun awaitTrigger(): T {
    var t: T? = null
    coroutineScope {
        val scope = this
        launch { t = awaitAutomaticTrigger(); scope.cancel() }
        launch { t = awaitManualTrigger(); scope.cancel() }
    }
    return t!!
}
```

[Louis CAD](https://hashnode.com/@LouisCAD)

[Nov 15, 2021](https://hashnode.com/posts/coroutines-racing-why-and-how/618a2953f991b025366df06f/comment/61925833fd3a1a5a01a8897b#reply-6192611efd3a1a5a01a88a34)

Can't work for the same reason as the other one you shared. For reference, here's a playground that proves it: [pl.kotl.in/MArMNltGT](https://pl.kotl.in/MArMNltGT)
