georgehao / oblog

Apache License 2.0
0 stars 0 forks source link

posts/2021-06-27-timer/ #2

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Go timer 是如何被调度的 | HHFCodeRv

Go timer 是如何被调度的? hi,大家好,我是 haohongfan。 本篇文章剖析下 Go 定时器的相关内容。定时器不管是业务开发,还是基础架构开发,都是绕不过去的存在,由此可见定时器的重要程度。 我们不管用 NewTimer, timer.After,还是 timer.AfterFun 来初始化一个 timer, 这个 timer 最终都会加入

https://www.haohongfan.com/posts/2021-06-27-timer/

shlande commented 2 years ago

感谢博主的好文 : )

就是有点没太看懂“正确使用”部分代码中的

if !timer1.Stop() {
     <-timer1.C
}

为什么要再去读timer呢?