[
https://issues.apache.org/jira/browse/HTRACE-170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14540625#comment-14540625
]
Vladimir Sitnikov commented on HTRACE-170:
------------------------------------------
Ah, that's true.
{quote}Would you like to create a patch replacing these usages with a
thread-local alternative?{quote}
So should it be {{ThreadLocal<Random>}} way? (e.g. utility class for random
that would be used everywhere)
> Optimize use of Random in htrace-core
> -------------------------------------
>
> Key: HTRACE-170
> URL: https://issues.apache.org/jira/browse/HTRACE-170
> Project: HTrace
> Issue Type: Bug
> Affects Versions: 3.3.0
> Reporter: Vladimir Sitnikov
>
> org.apache.htrace.Tracer#nonZeroRandom64 is obviously shares the same Random
> instance between multiple execution threads.
> That does not work.
> Either {{ThreadLocal<Random>}} (1.5+) or {{ThreadLocalRandom}} (1.7+) should
> be used.
> Other places with the same problem:
> org.apache.htrace.impl.CountSampler#random
> org.apache.htrace.impl.MilliSpan#nonZeroRandom64
> org.apache.htrace.impl.ProbabilitySampler#next
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)