I don't understand sync and sync/atomic. why where and when i should use this?

Why I should use sync/atomic?

Yep, i used sync for waiting a routine to be done. here sync helped me.

but why sync/atomic?

why it’s important in many other projects?

please read Dancing with Go’s Mutexes and Matt’s comment:

I might also add that if you find yourself mutexing integers, consider using sync/atomic’s primitive functions. These operations perform very well in high-load situations and don’t require you to manage a mutex.

2 Likes

One use case.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.