mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
31 lines
1.1 KiB
HTML
31 lines
1.1 KiB
HTML
<html>
|
|
<body>
|
|
Reports fields of types:
|
|
<ul>
|
|
<li><code>java.util.concurrent.atomic.AtomicLongFieldUpdater</code></li>
|
|
<li><code>java.util.concurrent.atomic.AtomicIntegerFieldUpdater</code></li>
|
|
<li><code>java.util.concurrent.atomic.AtomicReferenceFieldUpdater</code></li>
|
|
</ul>
|
|
that are not <code>static final</code>.
|
|
Because only one atomic field updater is needed for updating a <code>volatile</code> field in all instances
|
|
of a class, it can almost always be <code>static</code>.
|
|
|
|
<p>Making the updater <code>final</code> allows the JVM to optimize access for improved performance.</p>
|
|
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
class Main {
|
|
private volatile int id;
|
|
private AtomicIntegerFieldUpdater<Main> idFieldUpdater = AtomicIntegerFieldUpdater.newUpdater(Main.class, "id");
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
class Main {
|
|
private volatile int id;
|
|
private static final AtomicIntegerFieldUpdater<Main> idFieldUpdater = AtomicIntegerFieldUpdater.newUpdater(Main.class, "id");
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |