c语言sscanf函数的用法是什么
235
2022-11-28
go的cancel
type Ch struct { closeChan chan byte // 关闭通知}func main() { ctx, cancel := context.WithCancel(context.Background()) go func() { for { fmt.Println("1111") select { case s:= <-ctx.Done(): fmt.Println("1111333",s) } } }() for j:=0;j<100;j++ { go func(j int) { for { fmt.Println("2222") select { case <-ctx.Done(): fmt.Println("2222333",j) } } }(j) } go func() { for { fmt.Println("444") select { case <-ctx.Done(): fmt.Println("444333") } } }() time.Sleep(1*time.Second) for i:=0;i<10000;i++ { go func() { cancel() }() } cancel() for i:=0;i<10000;i++ { go func() { cancel() }() } time.Sleep(10*time.Second)}
go的cancel是高并发的
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~