- Learning Concurrency in Kotlin
- Miguel Angel Castiblanco Torres
- 181字
- 2021-08-05 10:46:51
Life cycle
Here's a diagram showing the life cycle of a job:

By default, a job is started as soon as it's created. This happens both when the job is created with launch() and when it's done with Job(). As we will see in a bit, it's possible to create a job without starting it.
There are five states in the diagram:
- New: A job that exists but is not executing yet.
- Active: A job that is running. A suspended job is also considered active.
- Completed: When the job is not executing any longer.
- Cancelling: When cancel() is called on a Job that is active, it may require time for the cancellation to complete. This is an intermediate state between Active and Cancelled.
- Cancelled: A job that has completed its execution due to cancellation. Note that a Cancelled job can be considered Completed too.
Note that if cancel() is called in a job in the New state, it will not go through the Cancelling state. It will directly go to Cancelled .
推薦閱讀
- 深入理解Android(卷I)
- 編程的修煉
- 圖解Java數據結構與算法(微課視頻版)
- 基于Java技術的Web應用開發
- 青少年美育趣味課堂:XMind思維導圖制作
- Django:Web Development with Python
- Apache Spark 2.x for Java Developers
- Spring快速入門
- Learning OpenStack Networking(Neutron)(Second Edition)
- CoffeeScript Application Development Cookbook
- CRYENGINE Game Development Blueprints
- Python Projects for Kids
- Docker:容器與容器云(第2版)
- 精益軟件開發管理之道
- Getting Started with Windows Server Security