Answer the question
In order to leave comments, you need to log in
How to work with concurrent access to one memory cell?
Small chat (for self-study) on GO. The "server" package has "map[string]net.Conn" where all active channels are stored.
I delete the empty channel from memory as soon as the last user exits.
During testing, I noticed that there are 2 different streams .. one is trying to delete an empty channel and the second is trying to write a new connection there.
It's not clear how to work with this.
Answer the question
In order to leave comments, you need to log in
Use mutexes when running concurrently with map
https://gobyexample.com/mutexes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question