Skip to content

Instantly share code, notes, and snippets.

@emopers
Created April 8, 2016 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emopers/da9b78139a4237c4cb200c063da30805 to your computer and use it in GitHub Desktop.
Save emopers/da9b78139a4237c4cb200c063da30805 to your computer and use it in GitHub Desktop.
Improve random number generation to reduce contention
In TraceCreator.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.
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