mardi 16 octobre 2018

Reusing java.util.Random instance vs creating a new instance every time

The title pretty much summarizes it - we can create one instance of java.util.Random (or SecureRandom) and use it every time we need a random value or we can create a new instance every time on demand. Wondering which one is the preferred way and why? To give some idea about the context: the random value is being generated inside an HTTP request handler, one per request, and I'm looking for the best combination for security and performance considering multithreading.




Aucun commentaire:

Enregistrer un commentaire