java.util.concurrent.atomic.AtomicBoolean.weakCompareAndSet()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(1.1k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中java.util.concurrent.atomic.AtomicBoolean.weakCompareAndSet()方法的一些代码示例,展示了AtomicBoolean.weakCompareAndSet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AtomicBoolean.weakCompareAndSet()方法的具体详情如下:
包路径:java.util.concurrent.atomic.AtomicBoolean
类名称:AtomicBoolean
方法名:weakCompareAndSet

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

相关文章