Getting different result from serial and multithreaded code in Julia

See these discussion

One solution appears to be using FLoops.jl FAQ · FLoops