java.lang.Object.notify()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(109)

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

Object.notify介绍

暂无

代码示例

代码示例来源:origin: apache/kafka

public void close() {
  synchronized (AbstractCoordinator.this) {
    this.closed = true;
    AbstractCoordinator.this.notify();
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Notifies an object for synchronization purposes.
 */
public static void notify(Object obj){
  synchronized (obj) {
    obj.notify();
  }
}

代码示例来源:origin: apache/incubator-druid

public void done()
{
 synchronized (singleByteReaderDoer) {
  done = true;
  singleByteReaderDoer.notify();
 }
}

代码示例来源:origin: apache/incubator-druid

public void exceptionCaught(Throwable t)
{
 synchronized (singleByteReaderDoer) {
  done = true;
  throwable = t;
  singleByteReaderDoer.notify();
 }
}

代码示例来源:origin: apache/flink

protected void stopRetrieval() {
  // stop retrieval
  refreshThread.isRunning = false;
  synchronized (refreshThread) {
    refreshThread.notify();
  }
}

代码示例来源:origin: apache/rocketmq

public void wakeup() {
  synchronized (this) {
    if (!this.hasNotified) {
      this.hasNotified = true;
      this.notify();
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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();
    }
  }
}

代码示例来源:origin: apache/incubator-druid

public void add(byte[] bytesToAdd)
{
 if (bytesToAdd.length == 0) {
  return;
 }
 synchronized (singleByteReaderDoer) {
  bytes.addLast(bytesToAdd);
  available += bytesToAdd.length;
  singleByteReaderDoer.notify();
 }
}

代码示例来源:origin: apache/incubator-druid

public void putRequest(final DruidPullRequest request)
{
 synchronized (this) {
  this.requestsWrite.add(request);
  if (!hasNotified) {
   hasNotified = true;
   notify();
  }
 }
}

代码示例来源:origin: spring-projects/spring-framework

public void stop() {
  synchronized(this.lock) {
    this.lock.notify();
  }
}

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

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();
  }
}

代码示例来源:origin: log4j/log4j

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();
  }
 }
}

代码示例来源:origin: apache/kafka

@Override
public synchronized void wakeup() {
  if (numBlockingWakeups > 0) {
    numBlockingWakeups--;
    notify();
  }
}

代码示例来源:origin: apache/kafka

public void enable() {
  synchronized (AbstractCoordinator.this) {
    log.debug("Enabling heartbeat thread");
    this.enabled = true;
    heartbeat.resetTimeouts();
    AbstractCoordinator.this.notify();
  }
}

代码示例来源:origin: apache/flink

protected void decreaseRefreshInterval(int minInterval) {
  refreshInterval = Math.max(minInterval, refreshInterval - 1);
  // reset view
  resetAllParts();
  synchronized (refreshThread) {
    refreshThread.notify();
  }
}

代码示例来源:origin: apache/flink

protected void increaseRefreshInterval() {
  refreshInterval = Math.min(REFRESH_INTERVALS.size() - 1, refreshInterval + 1);
  // reset view
  resetAllParts();
  synchronized (refreshThread) {
    refreshThread.notify();
  }
}

代码示例来源:origin: square/okio

@Override public void run() {
  synchronized (WaitUntilNotifiedTest.this) {
   WaitUntilNotifiedTest.this.notify();
  }
 }
}, 1000, TimeUnit.MILLISECONDS);

代码示例来源:origin: apache/incubator-dubbo

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();
        }
      }
    }
  }
}

代码示例来源:origin: apache/incubator-dubbo

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();
        }
      }
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

@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));
}

相关文章