/** * Constructor */ public Oliphaunt() { id = counter.incrementAndGet(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } }
private void put(final MySQLPacket mysqlPacket) { try { resultSet.put(mysqlPacket); } catch (final InterruptedException ex) { log.error(ex.getMessage(), ex); } }
@Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return true; }
@Override public void run() { try { while (count < size && subscribed) { if (null != values) { subscriber.onNext(values.get(count)); } else { subscriber.onNext(seed); } count++; //Unblock the main thread to call unsubscribe. if (null != once) { once.countDown(); } //Block until the main thread has called unsubscribe. if (null != okToContinue) { okToContinue.await(5, TimeUnit.SECONDS); } } if (subscribed) { subscriber.onComplete(); } } catch (InterruptedException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Override public void run() { lock.lock(); try { locked.countDown(); finishLatch.await(1, TimeUnit.MINUTES); } catch (InterruptedException e) { fail(e.toString()); } finally { lock.unlock(); } }
@Override public void run() { try { while (count < size && subscribed) { if (null != values) { observer.onNext(values.get(count)); } else { observer.onNext(seed); } count++; //Unblock the main thread to call unsubscribe. if (null != once) { once.countDown(); } //Block until the main thread has called unsubscribe. if (null != okToContinue) { okToContinue.await(5, TimeUnit.SECONDS); } } if (subscribed) { observer.onComplete(); } } catch (InterruptedException e) { e.printStackTrace(); fail(e.getMessage()); } }
@Override public void release() { try { ZookeeperMgr.getInstance().release(); } catch (InterruptedException e) { LOGGER.error(e.toString()); } }
@Override public void run() { LOGGER.info("{} processing {}", Thread.currentThread().getName(), task.toString()); try { Thread.sleep(task.getTimeMs()); } catch (InterruptedException e) { e.printStackTrace(); } } }
private void put(final MySQLPacket mysqlPacket) { try { resultSet.put(mysqlPacket); } catch (final InterruptedException ex) { log.error(ex.getMessage(), ex); } }
@Override public Future<V> await() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return this; }
@Test public void testConcurrent() { for (int i = 0; i < 10; i++) { TestRun run = new TestRun(this); set.add(run); Thread t = new Thread(run); t.setDaemon(true); t.start(); } logger.info("Thread creation over, " + set.size() + " still active."); synchronized (this) { while (!set.isEmpty() && ex == null) { try { wait(); } catch (InterruptedException e) { logger.info(e.toString()); } logger.info(set.size() + " threads still active."); } } if (ex != null) { fail(ex.getMessage()); } }
@Override public void run() { try { notifier.execute(Caller.this,question); } catch (InterruptedException e) { e.printStackTrace(); } } }).start();
@Override public boolean next() { try { MySQLPacket mysqlPacket = resultSet.take(); currentRow = (mysqlPacket instanceof TextResultSetRowPacket) ? (TextResultSetRowPacket) mysqlPacket : null; return null != currentRow; } catch (final InterruptedException ex) { log.error(ex.getMessage(), ex); } return false; }
@Override public VoidChannelPromise await() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return this; }
@Test public void testConcurrent() { for (int i = 0; i < 100; i++) { TestRun run = new TestRun(); run.setDaemon(true); set.add(run); } for (Iterator<TestRun> it = new HashSet<>(set).iterator(); it.hasNext();) { TestRun run = it.next(); run.start(); } logger.info("Thread creation over, " + set.size() + " still active."); synchronized (set) { while (!set.isEmpty() && ex == null) { try { set.wait(); } catch (InterruptedException e) { logger.info(e.toString()); } logger.info(set.size() + " threads still active."); } } if (ex != null) { fail(ex.getMessage()); } }
@Override public Integer apply(Integer t1) { if (c++ <= 1) { // slow try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } return t1; }
public void toStop(){ toStop = true; // interrupt and wait registryThread.interrupt(); try { registryThread.join(); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } }
@Override public boolean await(long timeoutMillis) throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return true; }
@Override public Integer apply(Integer t1) { if (c++ <= 1) { // slow try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } return t1; }
public void toStop(){ toStop = true; // interrupt and wait monitorThread.interrupt(); try { monitorThread.join(); } catch (InterruptedException e) { logger.error(e.getMessage(), e); } }