mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
18 lines
699 B
HTML
18 lines
699 B
HTML
<html>
|
|
<body>
|
|
Reports fields of type <code>java.lang.ThreadLocal</code> that are not declared <code>static final</code>.
|
|
<p>
|
|
In the most common case, a <code>java.lang.ThreadLocal</code> instance associates state with a thread.
|
|
A non-static non-final <code>java.lang.ThreadLocal</code> field associates state with an instance-thread combination.
|
|
This is usually unnecessary and quite often is a bug that can cause memory leaks and incorrect behavior.
|
|
</p>
|
|
<p>
|
|
A quick-fix is suggested to make the field <code>static final</code>.
|
|
<p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
private ThreadLocal tl = ThreadLocal.withInitial(() -> Boolean.TRUE);
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |