- Learning Concurrency in Kotlin
- Miguel Angel Castiblanco Torres
- 113字
- 2021-08-05 10:46:45
Suspending functions
Suspending functions are suspending computations in the shape of a function. A suspending function can be easily identified because of the modifier suspend. For example:
suspend fun greetAfter(name: String, delayMillis: Long) {
delay(delayMillis)
println("Hello, $name")
}
In the previous example, the execution of greetAfter() will be suspended when delay() is called – delay() is a suspending function itself, suspending the execution for a give duration. Once delay() has been completed, greetAfter() will resume its execution normally. And while greetAfter() is suspended, the thread of execution may be used to do other computations.
In Chapter 9, The Internals of Concurrency in Kotlin, we will talk about how this works behind the scenes.
推薦閱讀
- jQuery Mobile Web Development Essentials(Third Edition)
- 解構產品經理:互聯網產品策劃入門寶典
- Go語言高效編程:原理、可觀測性與優化
- 劍指MySQL:架構、調優與運維
- Terraform:多云、混合云環境下實現基礎設施即代碼(第2版)
- 從零開始學Linux編程
- Python語言實用教程
- Arduino Wearable Projects
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- Android Sensor Programming By Example
- Java EE Web應用開發基礎
- PHP項目開發全程實錄(第4版)
- 量子計算機編程:從入門到實踐
- 關系數據庫與SQL Server 2012(第3版)
- Getting Started with hapi.js