Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantLock.lockInterruptibly()


    if (guard.monitor != this) {
      throw new IllegalMonitorStateException();
    }
    final ReentrantLock lock = this.lock;
    boolean reentrant = lock.isHeldByCurrentThread();
    lock.lockInterruptibly();
    try {
      waitInterruptibly(guard, reentrant);
    } catch (Throwable throwable) {
      lock.unlock();
      throw Throwables.propagate(throwable);
View Full Code Here


  public boolean enterIfInterruptibly(Guard guard) throws InterruptedException {
    if (guard.monitor != this) {
      throw new IllegalMonitorStateException();
    }
    final ReentrantLock lock = this.lock;
    lock.lockInterruptibly();
    boolean satisfied;
    try {
      satisfied = guard.isSatisfied();
    } catch (Throwable throwable) {
      lock.unlock();
View Full Code Here

     */
    public void put(E e) throws InterruptedException {
        Importance i = (Importance) e;
        InternalQueue<E> internalQueue = getQueueForPriority(i.getPriority());
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            try {
                while (internalQueue.remainingCapacity() == 0) {
                    internalQueue.getNotFullCond().await();
                }
View Full Code Here

        Importance i = (Importance) e;
        InternalQueue<E> internalQueue = getQueueForPriority(i.getPriority());

        long nanos = unit.toNanos(timeout);
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            for (;;) {
                if (internalQueue.remainingCapacity() > 0) {
                    internalQueue.offer(e);
                    count++;
View Full Code Here

     * @return an element
     * @throws InterruptedException if the thread is interrupted
     */
    public E take() throws InterruptedException {
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            InternalQueue<E> internalQueue = nextQueueAlgorithm.getNextQueue();
            try {
                while (internalQueue == null) {
                    notEmpty.await();
View Full Code Here

     * @throws InterruptedException
     */
    public E poll(long timeout, TimeUnit unit) throws InterruptedException {
        long nanos = unit.toNanos(timeout);
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            for (;;) {
                InternalQueue<E> internalQueue = nextQueueAlgorithm.getNextQueue();
                if (internalQueue != null) {
                    E e = internalQueue.poll();
View Full Code Here

                                    }
                                }

                                log("Thread started, waiting for interruption");
                                try {
                                    interruptLock.lockInterruptibly();
                                } catch (InterruptedException e) {
                                    log("I was interrupted");
                                }
                            }
                        });
View Full Code Here

        return busySize;
    }
   
    private PooledConnection _getPooledConnection() throws InterruptedException, SQLException {
        final ReentrantLock lock = this.lock;
        lock.lockInterruptibly();
        try {
            if (doingShutdown) {
                throw new SQLException("Trying to access the Connection Pool when it is shutting down");
            }
           
View Full Code Here

   */
  @Override
  public boolean readWait(final TimeUnit unit, final long time,
                          final OutputStream outputStream, final BufferColor bufferColor) throws IOException, InterruptedException {
    final ReentrantLock lock = bufferColor.getLock();
    lock.lockInterruptibly();

    long nanos = unit.toNanos(time);

    try {
      for (; ; ) {
View Full Code Here

   */
  @Override
  public boolean readWait(TimeUnit unit, long time, OutputStream outputStream, final BufferColor bufferColor,
                          BufferCallback callback) throws IOException, InterruptedException {
    final ReentrantLock lock = bufferColor.lock;
    lock.lockInterruptibly();

    long nanos = time == -1 ? 1 : unit.toNanos(time);

    try {

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.