java.util.concurrent.locks.ReentrantLock.getWaitQueueLength()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(127)

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

ReentrantLock.getWaitQueueLength介绍

[英]Returns an estimate of the number of threads waiting on the given condition associated with this lock. Note that because timeouts and interrupts may occur at any time, the estimate serves only as an upper bound on the actual number of waiters. This method is designed for use in monitoring of the system state, not for synchronization control.
[中]返回等待与此锁关联的给定条件的线程数的估计值。请注意,由于超时和中断可能随时发生,因此估计值仅作为实际服务员人数的上限。该方法设计用于监控系统状态,而不是同步控制。

代码示例

代码示例来源:origin: alibaba/druid

public int getWaitThreadCount() {
  lock.lock();
  try {
    return lock.getWaitQueueLength(notEmpty);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: NLPchina/elasticsearch-sql

public int getWaitThreadCount() {
  lock.lock();
  try {
    return lock.getWaitQueueLength(notEmpty);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: com.alibaba/druid

public int getWaitThreadCount() {
  lock.lock();
  try {
    return lock.getWaitQueueLength(notEmpty);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: NLPchina/elasticsearch-sql

value.setWaitThreadCount(lock.getWaitQueueLength(notEmpty));
value.setNotEmptyWaitCount(this.notEmptyWaitCount);
value.setNotEmptyWaitNanos(this.notEmptyWaitNanos);

代码示例来源:origin: alibaba/druid

value.setWaitThreadCount(lock.getWaitQueueLength(notEmpty));
value.setNotEmptyWaitCount(this.notEmptyWaitCount);
value.setNotEmptyWaitNanos(this.notEmptyWaitNanos);

代码示例来源:origin: org.nlpcn/elasticsearch-sql

public int getWaitThreadCount() {
  lock.lock();
  try {
    return lock.getWaitQueueLength(notEmpty);
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: loveincode/Java-Multi-thread-Programming

public void notityMethod() {
  try {
    lock.lock();
    System.out.println("有" + lock.getWaitQueueLength(newCondition)
        + "个线程正在等待newCondition");
    newCondition.signal();
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: loveincode/Java-Multi-thread-Programming

public void notityMethod() {
  try {
    lock.lock();
    System.out.println("有没有线程正在等待newCondition?"
        + lock.hasWaiters(newCondition) + " 线程数是多少?"
        + lock.getWaitQueueLength(newCondition));
    newCondition.signal();
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: stackoverflow.com

ReentrantLock lock = new ReentrantLock();
lock.getQueueLength();
lock.getWaitQueueLength(condition);

代码示例来源:origin: kabutz/javaspecialists

public int getWaitQueueLength(Condition c) {
  return super.getWaitQueueLength(getRealCondition(c));
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod
public RubyNumeric num_waiting(ThreadContext context) {
  initializedCheck();
  final ReentrantLock takeLock = this.takeLock;
  final ReentrantLock putLock = this.putLock;
  try {
    takeLock.lockInterruptibly();
    try {
      putLock.lockInterruptibly();
      try {
        return context.runtime.newFixnum(takeLock.getWaitQueueLength(notEmpty) + putLock.getWaitQueueLength(notFull));
      } finally {
        putLock.unlock();
      }
    } finally {
      takeLock.unlock();
    }
  } catch (InterruptedException ie) {
    throw createInterruptedError(context, "num_waiting");
  }
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod
public RubyNumeric num_waiting(ThreadContext context) {
  initializedCheck();
  final ReentrantLock takeLock = this.takeLock;
  final ReentrantLock putLock = this.putLock;
  try {
    takeLock.lockInterruptibly();
    try {
      putLock.lockInterruptibly();
      try {
        return context.runtime.newFixnum(takeLock.getWaitQueueLength(notEmpty) + putLock.getWaitQueueLength(notFull));
      } finally {
        putLock.unlock();
      }
    } finally {
      takeLock.unlock();
    }
  } catch (InterruptedException ie) {
    throw createInterruptedError(context, "num_waiting");
  }
}

代码示例来源:origin: blazegraph/database

+ lock.getWaitQueueLength(unpaused));
+ lock.getWaitQueueLength(waiting));
+ lock.getWaitQueueLength(commit));

代码示例来源:origin: com.blazegraph/bigdata-core

+ lock.getWaitQueueLength(unpaused));
+ lock.getWaitQueueLength(waiting));
+ lock.getWaitQueueLength(commit));

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod
public RubyNumeric num_waiting(ThreadContext context) {
  initializedCheck();
  final ReentrantLock takeLock = this.takeLock;
  try {
    takeLock.lockInterruptibly();
    try {
      return context.runtime.newFixnum(takeLock.getWaitQueueLength(notEmpty));
    } finally {
      takeLock.unlock();
    }
  } catch (InterruptedException ie) {
    throw createInterruptedError(context, "num_waiting");
  }
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod
public RubyNumeric num_waiting(ThreadContext context) {
  initializedCheck();
  final ReentrantLock takeLock = this.takeLock;
  try {
    takeLock.lockInterruptibly();
    try {
      return context.runtime.newFixnum(takeLock.getWaitQueueLength(notEmpty));
    } finally {
      takeLock.unlock();
    }
  } catch (InterruptedException ie) {
    throw createInterruptedError(context, "num_waiting");
  }
}

代码示例来源:origin: anylogic/alogic

workingIncr(1);
idleIncr(-1);
waitCnt = lock.getQueueLength() + lock.getWaitQueueLength(notEmpty);

代码示例来源:origin: anylogic/alogic

waitCnt = lock.getQueueLength() + lock.getWaitQueueLength(notEmpty);
  return idleQueue.poll();
}catch (Exception ex){

代码示例来源:origin: anylogic/alogic

workingIncr(1);
idleIncr(-1);
waitCnt = lock.getQueueLength() + lock.getWaitQueueLength(notEmpty);

代码示例来源:origin: com.alibaba/druid

value.setWaitThreadCount(lock.getWaitQueueLength(notEmpty));
value.setNotEmptyWaitCount(this.notEmptyWaitCount);
value.setNotEmptyWaitNanos(this.notEmptyWaitNanos);

相关文章