当前位置: 首页>>代码示例>>Java>>正文


Java AtomicInteger.getAndDecrement方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.AtomicInteger.getAndDecrement方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicInteger.getAndDecrement方法的具体用法?Java AtomicInteger.getAndDecrement怎么用?Java AtomicInteger.getAndDecrement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.AtomicInteger的用法示例。


在下文中一共展示了AtomicInteger.getAndDecrement方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: poll

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E poll() {
    final AtomicInteger count = this.count;
    if (count.get() == 0)
        return null;
    E x = null;
    int c = -1;
    final ReentrantLock takeLock = this.takeLock;
    takeLock.lock();
    try {
        if (count.get() > 0) {
            x = dequeue();
            c = count.getAndDecrement();
            if (c > 1)
                notEmpty.signal();
        }
    } finally {
        takeLock.unlock();
    }
    if (c == capacity)
        signalNotFull();
    return x;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:LinkedBlockingQueue.java

示例2: poll

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E poll() {
    final AtomicInteger count = this.count;
    if (count.get() == 0)
        return null;
    E x = null;
    int c = -1;
    final ReentrantLock takeLock = this.takeLock;
    takeLock.lock();
    try {
        if (count.get() > 0) {
            x = extract();
            c = count.getAndDecrement();
            if (c > 1)
                notEmpty.signal();
        }
    } finally {
        takeLock.unlock();
    }
    if (c == capacity)
        signalNotFull();
    return x;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:PriorityPendingQueue.java

示例3: poll

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
    E x = null;
    int c = -1;
    long nanos = unit.toNanos(timeout);
    final AtomicInteger count = this.count;
    final ReentrantLock takeLock = this.takeLock;
    takeLock.lockInterruptibly();
    try {
        while (count.get() == 0) {
            if (nanos <= 0) return null;
            nanos = notEmpty.awaitNanos(nanos);
        }
        x = opQueue(null);
        c = count.getAndDecrement();
        if (c > 1) notEmpty.signal();
    } finally {
        takeLock.unlock();
    }
    if (c == capacity) signalNotFull();
    return x;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:PriorityBlockingQueue.java

示例4: take

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E take() throws InterruptedException {
    E x;
    int c = -1;
    final AtomicInteger count = this.count;
    final ReentrantLock takeLock = this.takeLock;
    takeLock.lockInterruptibly();
    try {
        try {
            while (count.get() == 0)
                notEmpty.await();
        } catch (InterruptedException ie) {
            notEmpty.signal(); // propagate to a non-interrupted thread
            throw ie;
        }
        x = extract();
        c = count.getAndDecrement();
        if (c > 1)
           notEmpty.signal();
        } finally {
        takeLock.unlock();
    }
    if (c == capacity)
        signalNotFull();
    return x;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:26,代码来源:PriorityPendingQueue.java

示例5: take

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
/** 从队列头部获取元素, size为空时等待 
 * @throws InterruptedException */
public E take() throws InterruptedException {
	E x;
       int c = -1;
       final AtomicInteger count = this.size;
       final ReentrantLock takeLock = this.takeLock;
       takeLock.lockInterruptibly();
       try {
           while (count.get() == 0) {
               notEmpty.await();
           }
           x = super.poll();
           c = count.getAndDecrement();
           if (c > 1)
               notEmpty.signal();
       } finally {
           takeLock.unlock();
       }
       if (c == Integer.MAX_VALUE)
           signalNotFull();
       return x;
}
 
开发者ID:NymphWeb,项目名称:nymph,代码行数:24,代码来源:NyQueue.java

示例6: take

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E take() throws InterruptedException {
    E x;
    int c = -1;
    final AtomicInteger count = this.count;
    final ReentrantLock takeLock = this.takeLock;
    takeLock.lockInterruptibly();
    try {
        while (count.get() == 0) {
            notEmpty.await();
        }
        x = dequeue();
        c = count.getAndDecrement();
        if (c > 1)
            notEmpty.signal();
    } finally {
        takeLock.unlock();
    }
    if (c == capacity)
        signalNotFull();
    return x;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:LinkedBlockingQueue.java

示例7: poll

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
    E x = null;
    int c = -1;
    long nanos = unit.toNanos(timeout);
    final AtomicInteger count = this.count;
    final ReentrantLock takeLock = this.takeLock;
    takeLock.lockInterruptibly();
    try {
        while (count.get() == 0) {
            if (nanos <= 0)
                return null;
            nanos = notEmpty.awaitNanos(nanos);
        }
        x = dequeue();
        c = count.getAndDecrement();
        if (c > 1)
            notEmpty.signal();
    } finally {
        takeLock.unlock();
    }
    if (c == capacity)
        signalNotFull();
    return x;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:LinkedBlockingQueue.java

示例8: take

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E take() throws InterruptedException {
  E x;
  int c = -1;
  final AtomicInteger count = this.count;
  final ReentrantLock takeLock = this.takeLock;
  takeLock.lockInterruptibly();
  try {
    while (count.get() == 0) {
      notEmpty.await();
    }
    x = dequeue();
    c = count.getAndDecrement();
    if (c > 1)
      notEmpty.signal();
  } finally {
    takeLock.unlock();
  }
  if (c == capacity)
    signalNotFull();
  return x;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:ForceableLinkedBlockingQueue.java

示例9: poll

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
public E poll(long timeout, TimeUnit unit) throws InterruptedException {
  E x = null;
  int c = -1;
  long nanos = unit.toNanos(timeout);
  final AtomicInteger count = this.count;
  final ReentrantLock takeLock = this.takeLock;
  takeLock.lockInterruptibly();
  try {
    while (count.get() == 0) {
      if (nanos <= 0)
        return null;
      nanos = notEmpty.awaitNanos(nanos);
    }
    x = dequeue();
    c = count.getAndDecrement();
    if (c > 1)
      notEmpty.signal();
  } finally {
    takeLock.unlock();
  }
  if (c == capacity)
    signalNotFull();
  return x;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:ForceableLinkedBlockingQueue.java

示例10: take

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
@Override
public E take () throws InterruptedException
{
   E x;
   int c = -1;
   final AtomicInteger count = this.count;
   final ReentrantLock takeLock = this.takeLock;
   takeLock.lockInterruptibly ();
   try
   {
      while (count.get () == 0)
      {
         notEmpty.await ();
      }
      x = getNext (true);
      c = count.getAndDecrement ();
      if (c > 1)
      {
         notEmpty.signal ();
      }
   }
   finally
   {
      takeLock.unlock ();
   }
   return x;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:28,代码来源:FairQueue.java

示例11: poll

import java.util.concurrent.atomic.AtomicInteger; //导入方法依赖的package包/类
@Override
public E poll (long timeout, TimeUnit unit) throws InterruptedException
{
   E x = null;
   int c = -1;
   long nanos = unit.toNanos (timeout);
   final AtomicInteger count = this.count;
   final ReentrantLock takeLock = this.takeLock;
   takeLock.lockInterruptibly ();
   try
   {
      while (count.get () == 0)
      {
         if (nanos <= 0)
         {
            return null;
         }
         nanos = notEmpty.awaitNanos (nanos);
      }
      x = getNext (true);
      c = count.getAndDecrement ();
      if (c > 1)
      {
         notEmpty.signal ();
      }
   }
   finally
   {
      takeLock.unlock ();
   }
   return x;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:33,代码来源:FairQueue.java


注:本文中的java.util.concurrent.atomic.AtomicInteger.getAndDecrement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。