Relative Content

Tag Archive for javamultithreadingrandom

Why java.util.Random need to be synchronized?

While writing a multithreaded application I encountered a problem that the multithreaded version runs as long as the single threaded one. I realize that I use java.util.Random shared between threads. So I change to ThreadLocalRandom.
I have a question, why is random designed in such a way that it requires thread synchronization? Same question for SecureRandom.