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

Use ThreadLocalConcurrent to Replace Random and Math.random

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.3, 3.7.0
    • Component/s: 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

              • Assignee:
                belugabehr David Mollitor
                Reporter:
                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