Withdrawn: CODETOOLS-7902839: JMH: Replace the use of ThreadLocal with explicitly managed thread map
Aleksey Shipilev
shade at openjdk.java.net
Wed Mar 10 09:21:14 UTC 2021
On Tue, 9 Mar 2021 14:33:04 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> SonarCloud instance reports the potential problem in BenchmarkHandler: 'Call "remove()" on "threadData"'
>
> private final ThreadLocal<ThreadData> threadData;
>
> This actually points to the lifecycle problem with `ThreadLocal`-s in `BenchmarkHandler`. We use it to pass and cache the thread-specific instances and thread parameters with benchmark threads, so that threads can reenter on each iteration and still have the same instances to work on.
>
> Normally, this would be cleaned up when Threads die. They normally do, as default `Executor` shuts down most of the time. But this is not the case for Executors that are not shut down, for example, common pool. In this case, `ThreadLocal`-s would be held until the VM exits.
>
> This should be cleaned up not to use `ThreadLocal`.
This pull request has been closed without being integrated.
-------------
PR: https://git.openjdk.java.net/jmh/pull/26
More information about the jmh-dev
mailing list