[Solved] Why is this function not thread safe in golang?

I haven’t analyzed all of it, but definitely the modification of mapStore from multiple goroutines is unsafe: mapStore[*res.someData] = append(mapStore[*res.someData], res) But as a starting point, run this under the race detector. It’ll find many problems for you. This is also clearly unsafe: resSlice := append(resSlice, res) But it also doesn’t quite do what you … Read more

[Solved] Java: two threads executing until the boolean flag is false: the second thread’s first run stops the first thread

this just isn’t how you’re supposed to work with threads. You have 2 major problems here: java memory model. Imagine that one thread writes to some variable, and a fraction of a second later, another thread reads it. If that would be guaranteed to work the way you want it to, that means that write … Read more