Java Code Examples for java.util.concurrent.locks.Lock#newCondition()

The following examples show how to use java.util.concurrent.locks.Lock#newCondition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppContext.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 2
Source File: AppContext.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 3
Source File: AppContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 4
Source File: AppContext.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 5
Source File: AppContext.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 6
Source File: AppContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 7
Source File: AppContext.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 8
Source File: AppContext.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor for AppContext.  This method is <i>not</i> public,
 * nor should it ever be used as such.  The proper way to construct
 * an AppContext is through the use of SunToolkit.createNewAppContext.
 * A ThreadGroup is created for the new AppContext, a Thread is
 * created within that ThreadGroup, and that Thread calls
 * SunToolkit.createNewAppContext before calling anything else.
 * That creates both the new AppContext and its EventQueue.
 *
 * @param   threadGroup     The ThreadGroup for the new AppContext
 * @see     sun.awt.SunToolkit
 * @since   1.2
 */
AppContext(ThreadGroup threadGroup) {
    numAppContexts.incrementAndGet();

    this.threadGroup = threadGroup;
    threadGroup2appContext.put(threadGroup, this);

    this.contextClassLoader =
         AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    return Thread.currentThread().getContextClassLoader();
                }
            });

    // Initialize push/pop lock and its condition to be used by all the
    // EventQueues within this AppContext
    Lock eventQueuePushPopLock = new ReentrantLock();
    put(EVENT_QUEUE_LOCK_KEY, eventQueuePushPopLock);
    Condition eventQueuePushPopCond = eventQueuePushPopLock.newCondition();
    put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond);
}
 
Example 9
Source File: MultiLangsStanfordCoreNLPClient.java    From blog-codes with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * This method creates an async call to the server, and blocks until the server
 * has finished annotating the object.
 */
@Override
public void annotate(Annotation annotation) {
  final Lock lock = new ReentrantLock();
  final Condition annotationDone = lock.newCondition();
  annotate(Collections.singleton(annotation), 1, (Annotation annInput) -> {
    try {
      lock.lock();
      annotationDone.signal();
    } finally {
      lock.unlock();
    }
  });
  try {
    lock.lock();
    annotationDone.await();  // Only wait for one callback to complete; only annotating one document
  } catch (InterruptedException e) {
    log.info("Interrupt while waiting for annotation to return");
  } finally {
    lock.unlock();
  }
}
 
Example 10
Source File: ConnectionNotificationsIntegrationTest.java    From nanofix with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotifyOnConnectionClosed() throws Exception
{
    FixClient fixClient;
    final Lock lock = new ReentrantLock();

    final Condition connectionEstablishedCondition = lock.newCondition();
    final Condition connectionClosedCondition = lock.newCondition();

    byteArrayOutputStream = new ByteArrayOutputStream();
    writableByteChannel = Channels.newChannel(byteArrayOutputStream);
    readableByteChannel = Channels.newChannel(new ByteArrayInputStream(new byte[0]));
    fixClient = FixClientFactory.createFixClient(new IntegrationSocketFactory(readableByteChannel, writableByteChannel));
    fixClient.registerTransportObserver(new SignallingConnectionObserver(lock, connectionEstablishedCondition, connectionClosedCondition));

    try
    {
        //when
        lock.lock();
        fixClient.connect();
        final boolean connectionClosed = connectionClosedCondition.await(5, TimeUnit.SECONDS);
        Assert.assertTrue(connectionClosed);
    }
    finally
    {
        lock.unlock();
    }
}
 
Example 11
Source File: AllocationQueue.java    From lite-pool with Apache License 2.0 5 votes vote down vote up
public AllocationQueue(Pool<T> pool, boolean fair) {
	//
	this.pool = pool; this.fifo = pool.getConfig().isFifo();
	final int v = Math.min(Math.max(pool.getConfig().getMaximum(), 32), 256);
	this.values = new ArrayList<>(v); this.index = new LongHashMap<>(v << 1);

	//
	lock = new ReentrantReadWriteLock(fair); Lock write = lock.writeLock();
	this.notFull = write.newCondition(); this.notEmpty = write.newCondition();
}
 
Example 12
Source File: IgnoredReturnValue.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@ExpectWarning("RV")
public static void main(String args[]) throws Exception {
    String str = " ttesting ";
    str.trim();
    str.toLowerCase();
    str.toUpperCase();
    str.replace(" ", "");
    str.replace(' ', '.');
    str.substring(0, 10);
    str.equals("testing");
    Semaphore s = new Semaphore(17, true);
    s.tryAcquire();
    s.tryAcquire(12, TimeUnit.MILLISECONDS);
    BlockingQueue<Object> q = new LinkedBlockingQueue<Object>();
    q.offer(new Object());
    q.offer(new Object(), 12, TimeUnit.MILLISECONDS);
    q.poll(12, TimeUnit.MILLISECONDS);
    q.poll();
    Lock l = new ReentrantLock();
    Condition c = l.newCondition();
    l.lock();
    try {
        c.awaitNanos(12);
        c.awaitUntil(new Date());
        c.await(12, TimeUnit.NANOSECONDS);
    } finally {
        l.unlock();
    }

    q.poll();
}
 
Example 13
Source File: ThriftHiveMetaStoreCore.java    From beeju with Apache License 2.0 5 votes vote down vote up
public void initialise() throws Exception {
  thriftPort = -1;
  final Lock startLock = new ReentrantLock();
  final Condition startCondition = startLock.newCondition();
  final AtomicBoolean startedServing = new AtomicBoolean();
  try (ServerSocket socket = new ServerSocket(0)) {
    thriftPort = socket.getLocalPort();
  }
  beejuCore.setHiveVar(HiveConf.ConfVars.METASTOREURIS, getThriftConnectionUri());
  final HiveConf hiveConf = new HiveConf(beejuCore.conf(), HiveMetaStoreClient.class);
  thriftServer.execute(new Runnable() {
    @Override
    public void run() {
      try {
        HadoopThriftAuthBridge bridge = new HadoopThriftAuthBridge23();
        HiveMetaStore.startMetaStore(thriftPort, bridge, hiveConf, startLock, startCondition, startedServing);
      } catch (Throwable e) {
        LOG.error("Unable to start a Thrift server for Hive Metastore", e);
      }
    }
  });
  int i = 0;
  while (i++ < 3) {
    startLock.lock();
    try {
      if (startCondition.await(1, TimeUnit.MINUTES)) {
        break;
      }
    } finally {
      startLock.unlock();
    }
    if (i == 3) {
      throw new RuntimeException("Maximum number of tries reached whilst waiting for Thrift server to be ready");
    }
  }
}
 
Example 14
Source File: AutomaticWorkQueueTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSchedule() throws Exception {
    workqueue = new AutomaticWorkQueueImpl(UNBOUNDED_MAX_QUEUE_SIZE, INITIAL_SIZE,
                                           UNBOUNDED_HIGH_WATER_MARK,
                                           UNBOUNDED_LOW_WATER_MARK,
                                           DEFAULT_DEQUEUE_TIMEOUT);
    final Lock runLock = new ReentrantLock();
    final Condition runCondition = runLock.newCondition();
    long start = System.currentTimeMillis();
    Runnable doNothing = new Runnable() {
        public void run() {
            runLock.lock();
            try {
                runCondition.signal();
            } finally {
                runLock.unlock();
            }
        }
    };

    workqueue.schedule(doNothing, 5000L);

    runLock.lock();
    try {
        runCondition.await();
    } finally {
        runLock.unlock();
    }

    assertTrue("expected delay",
               System.currentTimeMillis() - start >= 4950L);
}
 
Example 15
Source File: ConnectionNotificationsIntegrationTest.java    From nanofix with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotifyOnConnectionEstablished() throws Exception
{
    FixClient fixClient;
    final Lock lock = new ReentrantLock();

    final Condition connectionEstablishedCondition = lock.newCondition();
    final Condition connectionClosedCondition = lock.newCondition();

    byteArrayOutputStream = new ByteArrayOutputStream();
    writableByteChannel = Channels.newChannel(byteArrayOutputStream);
    readableByteChannel = Channels.newChannel(new ByteArrayInputStream(new byte[0]));
    fixClient = FixClientFactory.createFixClient(new IntegrationSocketFactory(readableByteChannel, writableByteChannel));
    fixClient.registerTransportObserver(new SignallingConnectionObserver(lock, connectionEstablishedCondition, connectionClosedCondition));

    try
    {
        //when
        lock.lock();
        fixClient.connect();
        final boolean connectionEstablished = connectionEstablishedCondition.await(5, TimeUnit.SECONDS);
        Assert.assertTrue(connectionEstablished);
    }
    finally
    {
        lock.unlock();
    }
}
 
Example 16
Source File: AsyncEndpointTest.java    From RoboZombie with Apache License 2.0 4 votes vote down vote up
/**
 * <p>Tests a successful asynchronous request where the implementation of the 
 * {@link AsyncHandler#onSuccess(HttpResponse, Object)} callback throws an exception.</p> 
 *  
 * @since 1.3.0
 */
@Test
public final void testAsyncSuccessCallbackError() throws InterruptedException {
	
	Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
	
	String subpath = "/successcallbackerror";
	
	stubFor(get(urlEqualTo(subpath))
			.willReturn(aResponse()
			.withStatus(200)));
	
	final Lock lock = new ReentrantLock();
	final Condition condition = lock.newCondition();
	
	asyncEndpoint.asyncSuccessCallbackError(new AsyncHandler<String>() {

		@Override
		public void onSuccess(HttpResponse httpResponse, String e) {

			try {
			
				throw new IllegalStateException();
			}
			finally {
				
				lock.lock();
				condition.signal();
				lock.unlock();
			}
		}
	});

	lock.lock();
	condition.await();
	lock.unlock();
	
	verify(getRequestedFor(urlEqualTo(subpath)));
	
	successScenario(); //verify that the asynchronous request executor has survived the exception
}
 
Example 17
Source File: AsyncEndpointTest.java    From RoboZombie with Apache License 2.0 4 votes vote down vote up
/**
 * <p>Tests asynchronous request execution with @{@link Async} and 
 * {@link AsyncHandler#onError(Exception)}.</p>
 *  
 * @since 1.3.0
 */
@Test
public final void testAsyncError() throws InterruptedException {
	
	Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
	
	String subpath = "/asyncerror", body = "non-JSON-content";
	
	stubFor(get(urlEqualTo(subpath))
			.willReturn(aResponse()
			.withStatus(200)
			.withBody(body)));
	
	final Object[] content = new Object[1];
	
	final Lock lock = new ReentrantLock();
	final Condition condition = lock.newCondition();
	
	asyncEndpoint.asyncError(new AsyncHandler<User>() {
		
		@Override
		public void onSuccess(HttpResponse httpResponse, User user) {}
		
		@Override
		public void onError(InvocationException error) {
			
			lock.lock();
			
			content[0] = error;
			condition.signal();
			
			lock.unlock();
		}
	});
	
	lock.lock();
	condition.await();
	lock.unlock();
	
	verify(getRequestedFor(urlEqualTo(subpath)));
	
	assertTrue(content[0] != null);
	assertTrue(content[0] instanceof InvocationException);
}
 
Example 18
Source File: AsyncEndpointTest.java    From RoboZombie with Apache License 2.0 4 votes vote down vote up
/**
 * <p>See {@link #testAsyncSuccess()}.</p>
 */
private void successScenario() throws InterruptedException {
	
	String subpath = "/asyncsuccess", body = "hello";
	
	stubFor(get(urlEqualTo(subpath))
			.willReturn(aResponse()
			.withStatus(200)
			.withBody(body)));

	final Object[] content = new Object[2];
	
	final Lock lock = new ReentrantLock();
	final Condition condition = lock.newCondition();
	
	String result = asyncEndpoint.asyncSuccess(new AsyncHandler<String>() {
		
		@Override
		public void onSuccess(HttpResponse httpResponse, String deserializedContent) {

			lock.lock();
			
			content[0] = httpResponse;
			content[1] = deserializedContent;
			
			condition.signal();
			lock.unlock();
		}
	});

	lock.lock();
	condition.await();
	lock.unlock();

	verify(getRequestedFor(urlEqualTo(subpath)));
	
	assertTrue(content[0] != null);
	assertTrue(content[1] != null);
	assertTrue(content[1].equals(body));
	
	assertNull(result);
}
 
Example 19
Source File: FXUtils.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
/**
 * Invokes a Runnable in JFX Thread and waits while it's finished. Like SwingUtilities.invokeAndWait does for EDT.
 *
 * @author hendrikebbers, original author
 * @author rstein, extension to Function, Supplier, Runnable
 * @param argument function argument
 * @param function transform function that should be executed within the JavaFX thread
 * @param <T> generic for argument type
 * @param <R> generic for return type
 * @return function result of type R
 * @throws Exception if a exception is occurred in the run method of the Runnable
 */
public static <T, R> R runAndWait(final T argument, final Function<T, R> function) throws Exception {
    if (Platform.isFxApplicationThread()) {
        return function.apply(argument);
    } else {
        final AtomicBoolean runCondition = new AtomicBoolean(true);
        final Lock lock = new ReentrantLock();
        final Condition condition = lock.newCondition();
        final ExceptionWrapper throwableWrapper = new ExceptionWrapper();

        final RunnableWithReturn<R> run = new RunnableWithReturn<>(() -> {
            R returnValue = null;
            lock.lock();
            try {
                returnValue = function.apply(argument);
            } catch (final Exception e) {
                throwableWrapper.t = e;
            } finally {
                try {
                    runCondition.set(false);
                    condition.signal();
                } finally {
                    runCondition.set(false);
                    lock.unlock();
                }
            }
            return returnValue;
        });
        lock.lock();
        try {
            Platform.runLater(run);
            while (runCondition.get()) {
                condition.await();
            }
            if (throwableWrapper.t != null) {
                throw throwableWrapper.t;
            }
        } finally {
            lock.unlock();
        }
        return run.getReturnValue();
    }
}
 
Example 20
Source File: SQLBlockingQueue.java    From extract with MIT License 4 votes vote down vote up
SQLBlockingQueue(final DataSource dataSource, final SQLCodec<E> codec, final Lock lock) {
	super(dataSource, codec);
	this.lock = lock;
	this.notEmpty = lock.newCondition();
}