default math.rand.source is thread save while rand.new source is not
Default math rand.Source is thread save while rand.New is not
Default pacakge rand uses Source that is thread safe with default seed 1
we can use the pacakge's method to have thread safe random number generation
But the rand.NewSource()
offers thread unsafe implementation. One of the reason to choose the unsafe implementation to avoid synchronization, especially when you have only single go routine.
Last updated