本文整理了Java中java.util.concurrent.Semaphore.reducePermits()
方法的一些代码示例,展示了Semaphore.reducePermits()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Semaphore.reducePermits()
方法的具体详情如下:
包路径:java.util.concurrent.Semaphore
类名称:Semaphore
方法名:reducePermits
[英]Shrinks the number of available permits by the indicated reduction. This method can be useful in subclasses that use semaphores to track resources that become unavailable. This method differs from acquire in that it does not block waiting for permits to become available.
[中]将可用许可证的数量减少指定的数量。这种方法在使用信号量跟踪不可用资源的子类中很有用。此方法与acquire的不同之处在于,它不会阻止等待许可证可用。
代码示例来源:origin: kairosdb/kairosdb
public void reducePermits(int reduction)
{
super.reducePermits(reduction);
}
}
代码示例来源:origin: palominolabs/sf-api-connector
@SuppressWarnings("EmptyMethod")
@Override
protected void reducePermits(int reduction) {
super.reducePermits(reduction);
}
}
代码示例来源:origin: allegro/hermes
@Override
protected void reducePermits(int reduction) {
super.reducePermits(reduction);
}
}
代码示例来源:origin: org.glassfish.connectors/connectors-runtime
@Override
protected void reducePermits(int size) {
super.reducePermits(size);
}
}
代码示例来源:origin: com.addthis/basis
@Override
protected void reducePermits(int reduction) {
super.reducePermits(reduction);
}
}
代码示例来源:origin: pl.allegro.tech.hermes/hermes-consumers
@Override
protected void reducePermits(int reduction) {
super.reducePermits(reduction);
}
}
代码示例来源:origin: stackoverflow.com
public class ResizeableSemaphore extends Semaphore
{
private static final long serialVersionUID = 1L;
private int permit;
public ResizeableSemaphore(int permit) {
super(permit);
this.permit=permit;
}
public synchronized void resizeIfRequired(int newPermit)
{
int delta = newPermit - permit;
if(delta==0) return;
if(delta > permit) this.release(delta); // this will increase capacity
if(delta < 0) this.reducePermits(Math.abs(delta));
this.permit=newPermit;
}
}
代码示例来源:origin: io.airlift/dbpool
@Managed
public synchronized void setPermits(int newPermits)
{
int delta = newPermits - this.permits;
if (delta > 0) {
// MUST call super since release on this method will modify active permits
super.release(delta);
}
else if (delta < 0) {
super.reducePermits(-delta);
}
this.permits = newPermits;
}
代码示例来源:origin: airlift/airlift
@Managed
public synchronized void setPermits(int newPermits)
{
int delta = newPermits - this.permits;
if (delta > 0) {
// MUST call super since release on this method will modify active permits
super.release(delta);
}
else if (delta < 0) {
super.reducePermits(-delta);
}
this.permits = newPermits;
}
内容来源于网络,如有侵权,请联系作者删除!