I have a prototype program looking like
function calculate(i) # do something, maybe expensive return eye(2)*rand() end s = zeros(2, 2) Thread.@thread for i in 1:100 s += calculate(i) end
I understand this program is not thread-safe since multiple threads may be accessing
s at the same time. However, since the document of multithreading is very short. I don’t know how to fix the problem. Anyone offer some help?