public class AtomicInteger extends Number implements Serializable
int値です。 原子変数のプロパティの詳細は、java.util.concurrent.atomicパッケージ仕様を参照してください。 AtomicIntegerは、原子的に増分されるカウンタなどのアプリケーションで使用されます。これをIntegerの代替として使用することはできません。 ただし、このクラスはNumberを拡張して、数値ベースのクラスを処理するツールやユーティリティによる単一的なアクセスを許可します。 | コンストラクタ | 説明 |
|---|---|
AtomicInteger() |
初期値
0を使って、新しいAtomicIntegerを作成します。 |
AtomicInteger(int initialValue) |
指定された初期パラメータを使って、新しいAtomicIntegerを作成します。
|
| 修飾子と型 | メソッド | 説明 |
|---|---|---|
int |
accumulateAndGet(int x, IntBinaryOperator accumulatorFunction) |
現在の値を、指定された関数を現在の値と指定された値に適用した結果で原子的に更新し、更新された値を返します。
|
int |
addAndGet(int delta) |
指定された値を現在の値に原子的に追加します。
|
boolean |
compareAndSet(int expect, int update) |
「現在の値
==予想される値」である場合、値を指定された更新値に原子的に設定します。 |
int |
decrementAndGet() |
現在の値を1だけ原子的に減分します。
|
double |
doubleValue() |
この
AtomicIntegerの拡張プリミティブ変換後の値をdoubleとして返します。 |
float |
floatValue() |
この
AtomicIntegerの拡張プリミティブ変換後の値をfloatとして返します。 |
int |
get() |
現在の値を取得します。
|
int |
getAndAccumulate(int x, IntBinaryOperator accumulatorFunction) |
現在の値を、指定された関数を現在の値と指定された値に適用した結果で原子的に更新し、前の値を返します。
|
int |
getAndAdd(int delta) |
指定された値を現在の値に原子的に追加します。
|
int |
getAndDecrement() |
現在の値を1だけ原子的に減分します。
|
int |
getAndIncrement() |
現在の値を1だけ原子的に増分します。
|
int |
getAndSet(int newValue) |
指定された値に原子的に設定して、以前の値を返します。
|
int |
getAndUpdate(IntUnaryOperator updateFunction) |
現在の値を、指定された関数を適用した結果で原子的に更新し、前の値を返します。
|
int |
incrementAndGet() |
現在の値を1だけ原子的に増分します。
|
int |
intValue() |
この
AtomicIntegerの値をintとして返します。 |
void |
lazySet(int newValue) |
指定された値に最終的に設定します。
|
long |
longValue() |
この
AtomicIntegerの拡張プリミティブ変換後の値をlongとして返します。 |
void |
set(int newValue) |
指定された値に設定します。
|
String |
toString() |
現在値の文字列表記を返します。
|
int |
updateAndGet(IntUnaryOperator updateFunction) |
現在の値を、指定された関数を適用した結果で原子的に更新し、更新された値を返します。
|
boolean |
weakCompareAndSet(int expect, int update) |
「現在の値
==予想される値」である場合、値を指定された更新値に原子的に設定します。 |
byteValue, shortValuepublic AtomicInteger(int initialValue)
initialValue - 初期値public AtomicInteger()
0を使って、新しいAtomicIntegerを作成します。public final int get()
public final void set(int newValue)
newValue - 新しい値public final void lazySet(int newValue)
newValue - 新しい値public final int getAndSet(int newValue)
newValue - 新しい値public final boolean compareAndSet(int expect,
int update)
==予想される値」である場合、値を指定された更新値に原子的に設定します。expect - 予想される値update - 新しい値true。 falseは、実際の値が予想される値と等価ではないことを示す。 public final boolean weakCompareAndSet(int expect,
int update)
==予想される値」である場合、値を指定された更新値に原子的に設定します。
見かけ上失敗する可能性があり、順序付け保証を提供しないため、compareAndSetの代わりに使用することはほとんどありません。
expect - 予想される値update - 新しい値truepublic final int getAndIncrement()
public final int getAndDecrement()
public final int getAndAdd(int delta)
delta - 追加する値public final int incrementAndGet()
public final int decrementAndGet()
public final int addAndGet(int delta)
delta - 追加する値public final int getAndUpdate(IntUnaryOperator updateFunction)
updateFunction - 副作用のない関数public final int updateAndGet(IntUnaryOperator updateFunction)
updateFunction - 副作用のない関数public final int getAndAccumulate(int x,
IntBinaryOperator accumulatorFunction)
x - 更新値accumulatorFunction - 2つの引数を取る、副作用のない関数public final int accumulateAndGet(int x,
IntBinaryOperator accumulatorFunction)
x - 更新値accumulatorFunction - 2つの引数を取る、副作用のない関数public int intValue()
AtomicIntegerの値をintとして返します。public long longValue()
AtomicIntegerの拡張プリミティブ変換後の値をlongとして返します。public float floatValue()
AtomicIntegerの拡張プリミティブ変換後の値をfloatとして返します。floatValue、クラスNumberfloat型に変換した値。public double doubleValue()
AtomicIntegerの拡張プリミティブ変換後の値をdoubleとして返します。doubleValue、クラスNumberdouble型に変換した値。 バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。