Skip to content
Update Kotlin coroutines authored by umaumax's avatar umaumax
...@@ -367,6 +367,25 @@ end 3 ...@@ -367,6 +367,25 @@ end 3
``` ```
となる となる
## 例
### クラスのフィールドでJobを扱う例
``` kotlin
import kotlinx.coroutines.*
class Hoge() {
private val coroutineScope = CoroutineScope(Dispatchers.Default)
private var job: Job? = null
suspend fun start() {
// TODO: write here
}
suspend fun stop() {
// TODO: write here
}
}
```
## 注意 ## 注意
### GlobalScope ### GlobalScope
[Kotlin コルーチン 1.5: GlobalScope がデリケート扱いに、チャンネル API の改善など | The Kotlin Blog]( https://blog.jetbrains.com/ja/kotlin/2021/06/kotlin-coroutines-1-5-0-released-ja/ ) [Kotlin コルーチン 1.5: GlobalScope がデリケート扱いに、チャンネル API の改善など | The Kotlin Blog]( https://blog.jetbrains.com/ja/kotlin/2021/06/kotlin-coroutines-1-5-0-released-ja/ )
... ...
......