本文整理了Java中java.util.concurrent.atomic.AtomicBoolean.weakCompareAndSet()
方法的一些代码示例,展示了AtomicBoolean.weakCompareAndSet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AtomicBoolean.weakCompareAndSet()
方法的具体详情如下:
包路径:java.util.concurrent.atomic.AtomicBoolean
类名称:AtomicBoolean
方法名:weakCompareAndSet
[英]Atomically sets the value to the given updated value if the current value == the expected value.
May fail spuriously and does not provide ordering guarantees, so is only rarely an appropriate alternative to compareAndSet.
[中]如果当前值==预期值,则自动将该值设置为给定的更新值。
May fail spuriously and does not provide ordering guarantees,so很少是compareAndSet的合适替代品。
代码示例来源:origin: com.athaydes.rawhttp/rawhttp-core
headerNames.removeIf(name -> {
boolean found = name.equalsIgnoreCase(headerName);
if (found && foundFirst.weakCompareAndSet(false, true)) {
return false; // leave the first value
代码示例来源:origin: renatoathaydes/rawhttp
headerNames.removeIf(name -> {
boolean found = name.equalsIgnoreCase(headerName);
if (found && foundFirst.weakCompareAndSet(false, true)) {
return false; // leave the first value
内容来源于网络,如有侵权,请联系作者删除!