Created
April 8, 2016 19:43
-
-
Save emopers/47aff18d51afcbc38b938e2af0c3869b to your computer and use it in GitHub Desktop.
Improve random number generation to reduce contention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In RealTimePlayer.java, Math.random() is used for random number generation. | |
According to Java API (Link: http://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#random--), | |
it's suggested that each thread has their own random number generator to reduce contention. | |
The increasing in contention might have a significant effect since the random number generation is | |
in Thread implementation. | |
This pull request improved the condition by replacing Math.random() with Random.nextInt(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment