Concurrent calls to time.Timer.Reset

65 views
Skip to first unread message

Duncan Harris

unread,
Oct 13, 2025, 8:17:05 PM (2 days ago) Oct 13
to golang-nuts
Is it safe to make calls to time.Timer.Reset on the same timer instance from multiple goroutines? Or should these always be done in the same goroutine?

Ian Lance Taylor

unread,
Oct 13, 2025, 8:46:13 PM (2 days ago) Oct 13
to Duncan Harris, golang-nuts
On Mon, Oct 13, 2025 at 5:17 PM Duncan Harris <dun...@harris3.org> wrote:
>
> Is it safe to make calls to time.Timer.Reset on the same timer instance from multiple goroutines? Or should these always be done in the same goroutine?

It is safe in the sense that the program will not crash and the timer
data structures will be fine. Of course it is unpredictable which
Reset will finally take effect.

Ian
Reply all
Reply to author
Forward
0 new messages