You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "M. Justin (Jira)" <ji...@apache.org> on 2024/06/25 18:21:00 UTC
[jira] [Commented] (LANG-1254) ThreadLocalRandom should be used in utility classes
[ https://issues.apache.org/jira/browse/LANG-1254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17860000#comment-17860000 ]
M. Justin commented on LANG-1254:
---------------------------------
This can be closed as resolved since it was fixed in 3.13.0 per commit [DMI: Random object created and used only once|https://github.com/apache/commons-lang/commit/2978cb6cf05379fd42374eb5a235be84e021f247].
[Release 3.13.0 – 2023-07-23|https://commons.apache.org/proper/commons-lang/changes-report.html#a3.13.0]:
> DMI: Random object created and used only once (DMI_RANDOM_USED_ONLY_ONCE); Better multi-threaded behavior. Thanks to SpotBugs, Gary Gregory.
> ThreadLocalRandom should be used in utility classes
> ---------------------------------------------------
>
> Key: LANG-1254
> URL: https://issues.apache.org/jira/browse/LANG-1254
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: John Mark
> Priority: Minor
>
> I noticed that both {{RandomUtils}} and {{RandomStringUtils}} use a constant for the {{Random}} instance. The javadoc for [Random|http://docs.oracle.com/javase/8/docs/api/java/util/Random.html] indicates that [ThreadLocalRandom|http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadLocalRandom.html] should be used for performance in multithreaded designs. I would think that a public utility class would qualify as a multithreaded design and should therefore use {{ThreadLocalRandom}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)