|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.util.concurrent.atomic.AtomicBoolean
public class AtomicBoolean
可以用原子方式更新的 boolean 值。有关原子变量属性的描述,请参阅 java.util.concurrent.atomic 包规范。AtomicBoolean 可用在应用程序中(如以原子方式更新的标志),但不能用于替换 Boolean。
| 构造方法摘要 | |
|---|---|
AtomicBoolean()
使用初始值 false 创建新的 AtomicBoolean。 |
|
AtomicBoolean(boolean initialValue)
使用给定的初始值创建新的 AtomicBoolean。 |
|
| 方法摘要 | |
|---|---|
boolean |
compareAndSet(boolean expect,
boolean update)
如果当前值 == 预期值,则以原子方式将该值设置为给定的更新值。 |
boolean |
get()
返回当前值。 |
boolean |
getAndSet(boolean newValue)
以原子方式设置为给定值,并返回以前的值。 |
void |
lazySet(boolean newValue)
最终设置为给定值。 |
void |
set(boolean newValue)
无条件地设置为给定值。 |
String |
toString()
返回当前值的字符串表示形式。 |
boolean |
weakCompareAndSet(boolean expect,
boolean update)
如果当前值 == 预期值,则以原子方式将该值设置为给定的更新值。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
public AtomicBoolean(boolean initialValue)
AtomicBoolean。
initialValue - 初始值public AtomicBoolean()
false 创建新的 AtomicBoolean。
| 方法详细信息 |
|---|
public final boolean get()
public final boolean compareAndSet(boolean expect,
boolean update)
== 预期值,则以原子方式将该值设置为给定的更新值。
expect - 预期值update - 新值
public boolean weakCompareAndSet(boolean expect,
boolean update)
== 预期值,则以原子方式将该值设置为给定的更新值。
可能意外失败并且不提供排序保证,因此几乎只是 compareAndSet 的适当替代方法。
expect - 预期值update - 新值
public final void set(boolean newValue)
newValue - 新值public final void lazySet(boolean newValue)
newValue - 新值public final boolean getAndSet(boolean newValue)
newValue - 新值
public String toString()
Object 中的 toString
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。