当前位置:网站首页>Kotlin 协程,job的生命周期
Kotlin 协程,job的生命周期
2022-06-13 00:36:00 【安果移不动】
通过async 或者 launch 创建的方法体会返回一个Job实例,该实例是携程的唯一标识,并且负责管理协程的生命周期。
一个任务可以包含一系列的状态,
新创建(New),活跃(Active),完成中(Completing)已完成 (Completed)、取消中(Cancelling)和已取消(Cancelled)
虽然我们无法直接访问这些状态,但是我们可以通过访问Job的属性
isActive\isCancelled\isCompleted
如果协程出于活跃状态,
协程运行出错或调用job.cancel()
都会将当前任务置为取消中(Cancelling)状态(isActive=false,isCancelled=true)
当所有子协程都完成后,协程会进入取消(Cancelled)状态,此时 isCompleted=true

边栏推荐
- @Disallowcurrentexecution prevents quartz scheduled tasks from executing in parallel
- ImportError: cannot import name 'get_ora_doc' from partially initialized module
- Delphi Chinese digit to Arabic digit
- ROS2之OpenCV人脸识别foxy~galactic~humble
- ucore lab2
- 人神共愤,唐山“群殴女性事件”细节...
- Browser console injection JS
- Stm32f4 development of DMA transmission to GPIO port
- Summary of openstack installation problems
- MASA Auth - 从用户的角度看整体设计
猜你喜欢

Arduino controls tb6600 driver +42 stepper motor

阿姨学代码续集:能力吊打大批程序员
![[gxyctf2019] no dolls -- detailed explanation](/img/c8/8c588ab8f58e2b38b9c64c4ccd733f.png)
[gxyctf2019] no dolls -- detailed explanation

Stack overflow learning summary

Cve-2021-24078 vulnerability analysis
![BUUCTF之BabyUpload[GXYCTF2019]](/img/e8/202298b64d8764355fad348b50fee6.png)
BUUCTF之BabyUpload[GXYCTF2019]
![[GYCTF2020]Ezsqli --BUUCTF](/img/8b/3c8b48daf7719482a235fd622737aa.png)
[GYCTF2020]Ezsqli --BUUCTF

Mysql批量插入数据时如何解决重复问题?

Target recognition gadget

DNS attack surface analysis
随机推荐
Oceanbase is the leader in the magic quadrant of China's database in 2021
USTC of China University of science and technology: Minrui Wang | distribution network voltage stabilization based on transformer Multi-Agent Reinforcement Learning
Assembly language learning
DNS attack surface analysis
Influence of higher order poles on waveform
ImportError: cannot import name 'get_ora_doc' from partially initialized module
MySQL queries the quantity of each month and the year-on-year and month on month data of each month
[colorful] Net dto mapping
Stack overflow learning summary
[buglist] serial port programming does not read data
BUUCTF之BabyUpload[GXYCTF2019]
Programming training 1
[gxyctf2019] no dolls -- detailed explanation
The origin of MySQL in bedtime stories
[Error] invalid use of incomplete type 使用了未定义的类型
What are the levels of safety accidents
2022施工員-設備方向-通用基礎(施工員)操作證考試題及模擬考試
Building crud applications in golang
Solution to the problem of closing the watchdog of STM32 in the sleep mode (stop/standby)
Three kinds of thinking make me reborn