How do I generate thread-safe uniform random numbers?

前端 未结 5 655
渐次进展
渐次进展 2020-12-01 03:53

My program needs to generate many random integers in some range (int min, int max). Each call will have a different range. What is a good (preferably thread-safe) w

5条回答
  •  無奈伤痛
    2020-12-01 04:04

    You can use one default_random_engine per thread using Thread Local Storage.

    I can not tell you how to correctly use TLS since it is OS dependent. The best source you can use is to search through the internet.

提交回复
热议问题