public void close() { synchronized (AbstractCoordinator.this) { this.closed = true; AbstractCoordinator.this.notify(); } }
/** * Notifies an object for synchronization purposes. */ public static void notify(Object obj){ synchronized (obj) { obj.notify(); } }
public void done() { synchronized (singleByteReaderDoer) { done = true; singleByteReaderDoer.notify(); } }
public void exceptionCaught(Throwable t) { synchronized (singleByteReaderDoer) { done = true; throwable = t; singleByteReaderDoer.notify(); } }
protected void stopRetrieval() { // stop retrieval refreshThread.isRunning = false; synchronized (refreshThread) { refreshThread.notify(); } }
public void wakeup() { synchronized (this) { if (!this.hasNotified) { this.hasNotified = true; this.notify(); } } }
/** * To be invoked after the main execution logic of concrete subclasses. * @see #beforeAccess() */ protected void afterAccess() { if (this.concurrencyLimit >= 0) { synchronized (this.monitor) { this.concurrencyCount--; if (logger.isDebugEnabled()) { logger.debug("Returning from throttle at concurrency count " + this.concurrencyCount); } this.monitor.notify(); } } }
public void add(byte[] bytesToAdd) { if (bytesToAdd.length == 0) { return; } synchronized (singleByteReaderDoer) { bytes.addLast(bytesToAdd); available += bytesToAdd.length; singleByteReaderDoer.notify(); } }
public void putRequest(final DruidPullRequest request) { synchronized (this) { this.requestsWrite.add(request); if (!hasNotified) { hasNotified = true; notify(); } } }
public void stop() { synchronized(this.lock) { this.lock.notify(); } }
class BlockingQueue { Queue<String> buffer = new LinkedList<String>(); public void give(String data) { buffer.add(data); notify(); // Since someone may be waiting in take! } public String take() throws InterruptedException { while (buffer.isEmpty()) // don't use "if" due to spurious wakeups. wait(); return buffer.remove(); } }
void close() { synchronized (bf) { interrupted = true; // We have a waiting dispacther if and only if bf.length is // zero. In that case, we need to give it a death kiss. if (bf.length() == 0) { bf.notify(); } } }
@Override public synchronized void wakeup() { if (numBlockingWakeups > 0) { numBlockingWakeups--; notify(); } }
public void enable() { synchronized (AbstractCoordinator.this) { log.debug("Enabling heartbeat thread"); this.enabled = true; heartbeat.resetTimeouts(); AbstractCoordinator.this.notify(); } }
protected void decreaseRefreshInterval(int minInterval) { refreshInterval = Math.max(minInterval, refreshInterval - 1); // reset view resetAllParts(); synchronized (refreshThread) { refreshThread.notify(); } }
protected void increaseRefreshInterval() { refreshInterval = Math.min(REFRESH_INTERVALS.size() - 1, refreshInterval + 1); // reset view resetAllParts(); synchronized (refreshThread) { refreshThread.notify(); } }
@Override public void run() { synchronized (WaitUntilNotifiedTest.this) { WaitUntilNotifiedTest.this.notify(); } } }, 1000, TimeUnit.MILLISECONDS);
protected void registered(URL url) { for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) { URL key = entry.getKey(); if (UrlUtils.isMatch(key, url)) { Set<URL> urls = received.get(key); if (urls == null) { received.putIfAbsent(key, new ConcurrentHashSet<URL>()); urls = received.get(key); } urls.add(url); List<URL> list = toList(urls); for (NotifyListener listener : entry.getValue()) { notify(key, listener, list); synchronized (listener) { listener.notify(); } } } } }
protected void registered(URL url) { for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) { URL key = entry.getKey(); if (UrlUtils.isMatch(key, url)) { Set<URL> urls = received.get(key); if (urls == null) { received.putIfAbsent(key, new ConcurrentHashSet<URL>()); urls = received.get(key); } urls.add(url); List<URL> list = toList(urls); for (NotifyListener listener : entry.getValue()) { notify(key, listener, list); synchronized (listener) { listener.notify(); } } } } }
@Override public void run() { if (this.acceptOnExecution) { this.workListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, this.work, null)); } synchronized (this.monitor) { this.started = true; this.monitor.notify(); } this.workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, this.work, null)); try { this.work.run(); } catch (RuntimeException | Error ex) { this.workListener.workCompleted( new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(ex))); throw ex; } this.workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, null)); }