当前位置:网站首页>【Golang】- runtime.Goexit()
【Golang】- runtime.Goexit()
2022-07-29 01:51:00 【JavaPub-rodert】
Blogger introduction : We-Media JavaPub Independent maintainer , Fans all over the Internet 15w+,csdn Blogger 、java Quality creators in the field ,51ctoTOP10 Blogger , You know / Nuggets / Hua Wei Yun / Alibaba cloud /InfoQ And other high-quality authors 、 Focus on Java、
GoLangTechnical fields and sidelines .GoLang More convenient to learn , One article in hand , I have
GoLang interview | GoLang interview | GoLang interview
List of articles
Go The concurrency model of the language basically follows CSP Model ,goroutine Completely depend on channel signal communication , Didn't like Unix Process wait or waitpid Waiting mechanism , There is no such thing “POSIX Thread” Medium pthread_join The convergence mechanism of , More like kill or signal This kind of interrupt mechanism . Every goroutine Exit and destroy by yourself after completion , Without a trace .
/** Goexit call runtime.goExit() The current... Will be terminated immediately goroutine perform , Scheduler Make sure all are registered defer Delayed scheduling is performed . */
package main
import (
"fmt"
"runtime"
)
func main(){
go func(){
defer fmt.Println("A defer go")
func(){
defer fmt.Println("B defer go")
runtime.Goexit()
fmt.Println("B")
}()
fmt.Println("A")
}()// Don't forget ()
// Blocking , Prevent end
for{
}
// Output
/** F:\goWorkSpace\study\05 coroutines >go run 06_runtimeGoexit.go B defer go A defer go */
}
call runtime.goExit() The current... Will be terminated immediately goroutine perform , The scheduler ensures that all are registered defer Delayed scheduling is performed .

边栏推荐
- Window object of BOM series
- [netding cup 2020 rosefinch group]nmap
- 【流放之路-第六章】
- Focus on differentiated product design, intelligent technology efficiency improvement and literacy education around new citizen Finance
- Comprehensive upgrade, all you can imagine is here -- JD API interface
- BOM系列之定时器
- Tda75610-i2c-determination of I2C address of analog power amplifier
- What are the common cyber threats faced by manufacturers and how do they protect themselves
- It is found that the data of decimal type in the database can be obtained through resultset.getdouble, but this attribute cannot be obtained through GetObject.
- 活动速递| Apache Doris 性能优化实战系列直播课程初公开,诚邀您来参加!
猜你喜欢

What are the common cyber threats faced by manufacturers and how do they protect themselves

The brutal rule of blackmail software continues, and attacks increase by 105%

J9 number theory: what factors determine the value of NFT?

Analysis of Multi Chain use cases on moonbeam -- review of Derek's speech in Polkadot decoded 2022

【Web技术】1395- Esbuild Bundler HMR

Plato launched the LAAS protocol elephant swap, which allows users to earn premium income

Merkel Studio - harmonyos implementation list to do

我们总结了 3 大Nacos使用建议,并首次公开 Nacos 3.0 规划图 Nacos 开源 4 周年

明日无限计划,2022某公司元宇宙产品发布会活动概念策划方案

Leetcode 113: path sum II
随机推荐
【7.21-26】代码源 - 【体育节】【丹钓战】【最大权值划分】
Sigma-DSP-OUTPUT
[机缘参悟-54]:《素书》-1-事物缘起[原始章第一]:大道至简。
Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
internship:用于类型判断的工具类编写
[WesternCTF2018]shrine
[7.21-26] code source - [square count] [dictionary order minimum] [Z-type matrix]
活动速递| Apache Doris 性能优化实战系列直播课程初公开,诚邀您来参加!
5G 商用第三年:无人驾驶的“上山”与“下海”
What is the ISO assessment? How to do the waiting insurance scheme
numpy.where() 用法和np.argsort()的用法
How many of the top ten test tools in 2022 do you master
10 major network security incidents in the past 10 years
【流放之路-第六章】
560 和为 K 的子数组
Reinforcement learning (III): dqn, nature dqn, double dqn, with source code interpretation
Anaconda environment installation problem
HCIA配置实例(eNSP)
Comprehensive upgrade, complete collection of Taobao / tmall API interfaces
Read the recent trends of okaleido tiger and tap the value and potential behind it
