# Thread Local Randoms in Java

DevFeed: [Thread Local Randoms in Java](<https://devfeed.tech/articles/thread-local-randoms-in-java-24841.md>)

Original publisher: [Read original article](<https://alidg.me/blog/2020/4/24/thread-local-random>)

Author: Alimate

Published: 2020-04-24T00:00:00Z

Content type: tutorial

Language: en

Sources: [Ali Dehghan - Kemikit](<https://devfeed.tech/sources/ali-dehghan-kemikit.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [Randomizer](<https://devfeed.tech/topics/randomizer.md>), [benchmarking](<https://devfeed.tech/topics/benchmarking.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [atomics](<https://devfeed.tech/tags/atomics.md>), [benchmarking](<https://devfeed.tech/tags/benchmarking.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [java](<https://devfeed.tech/tags/java.md>), [lock-free](<https://devfeed.tech/tags/lock-free.md>), [performance](<https://devfeed.tech/tags/performance.md>), [state](<https://devfeed.tech/tags/state.md>)

## AI overview

This article examines thread-local random number generation in Java. It compares a shared generator, a simple thread-local implementation, and the built-in approach, explaining how contention, atomic operations, synchronization, and shared mutable state affect throughput.

## Source excerpt

Benchmarking regular randoms against thread-local ones!