Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
I'd go for the mutex because I like mute peope and atomic sounds too radioactive.
Edit: I'm drunk.
h0ru5610dNeither, if possible. I always try to block on channel read in those situations.
a mutex will ensure that only one concurrent thread/goroutine will execute a piece of code or interact with data protected by the mutex - the next one will wait until the mutex is open.
an atomic is ensuring that a block of interactions will be done as a whole, e.g. updates of several values, thus if someone reads the data while it is being written, they get a senseful state.
a channel is sending messages from a to b, avoiding several threads or goroutines handle the same data object or run the same piece of code.
Your Job Suck?
Take a quick quiz from Triplebyte to skip the job search hassles and jump to final interviews at hot tech firms
Get a Better Job