Is Random class thread safe?

前端 未结 8 956
臣服心动
臣服心动 2020-12-13 11:53

Is it valid to share one instance of the Random class between multiple threads? And to call nextInt(int) from multiple threads in particular?

8条回答
  •  既然无缘
    2020-12-13 12:19

    It is thread safe, although it wasn't always.

    See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6362070 for more details.

提交回复
热议问题