摘要: package main import ( "fmt" "sync" ) var n int var lock sync.RWMutex func main() { wg := sync.WaitGroup{} wg.Add(1000) for i:=0; i<1000; i++ { go func 阅读全文
posted @ 2022-10-16 19:42 AngDH 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-10-16 18:46 AngDH 阅读(10) 评论(0) 推荐(0) 编辑
摘要: package main func main() { defer println("defer 1") level1() } func level1() { defer println("defer 2") defer func() { if err := recover(); err != nil 阅读全文
posted @ 2022-10-16 18:38 AngDH 阅读(43) 评论(0) 推荐(0) 编辑
摘要: package main import "fmt" import "sync" import "time" var oc sync.Once var a int = 5; func main() { go func(){ oc.Do(func(){ a++ }) }() go func(){ oc. 阅读全文
posted @ 2022-10-16 00:40 AngDH 阅读(18) 评论(0) 推荐(0) 编辑