Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-3671

Use ThreadLocalConcurrent to Replace Random and Math.random

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.6.3, 3.7.0
    • None

    Description

      ThreadLocalRandom is a combination of ThreadLocal and Random classes, which is isolated to the current thread. Thus, it achieves better performance in a multithreaded environment by simply avoiding any concurrent access to the Random objects.

      https://www.baeldung.com/java-thread-local-random

      I also had a conversation with a Oracle Java engineer that indicated that ThreadLocalRandom is preferable with new development.

      Attachments

        Issue Links

          Activity

            People

              belugabehr David Mollitor
              belugabehr David Mollitor
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h
                  3h