Tabnine Logo
Object.wait
Code IndexAdd Tabnine to your IDE (free)

How to use
wait
method
in
java.lang.Object

Best Java code snippets using java.lang.Object.wait (Showing top 20 results out of 34,560)

origin: square/okhttp

/** For testing: waits until {@code requiredPongCount} pings have been received from the peer. */
synchronized void awaitPong() throws InterruptedException {
 while (awaitingPong) {
  wait();
 }
}
origin: stackoverflow.com

 Object mon = ...;
synchronized (mon) {
  mon.wait();
}
origin: jenkinsci/jenkins

/**
 * Blocks until the event becomes the signaled state.
 *
 * <p>
 * This method blocks infinitely until a value is offered.
 */
public void block() throws InterruptedException {
  synchronized (lock) {
    while(!signaled)
      lock.wait();
  }
}
origin: apache/kafka

synchronized R await() throws InterruptedException, ExecutionException {
  while (true) {
    if (exception != null)
      wrapAndThrow(exception);
    if (done)
      return value;
    this.wait();
  }
}
origin: square/okhttp

/**
 * Like {@link #wait}, but throws an {@code InterruptedIOException} when interrupted instead of
 * the more awkward {@link InterruptedException}.
 */
void waitForIo() throws InterruptedIOException {
 try {
  wait();
 } catch (InterruptedException e) {
  Thread.currentThread().interrupt(); // Retain interrupted status.
  throw new InterruptedIOException();
 }
}
origin: iluwatar/java-design-patterns

@Override
public void lock() {
 synchronized (globalMutex) {
  // Wait until the lock is free.
  while (!isLockFree()) {
   try {
    globalMutex.wait();
   } catch (InterruptedException e) {
    LOGGER.info("InterruptedException while waiting for globalMutex to begin writing", e);
    Thread.currentThread().interrupt();
   }
  }
  // When the lock is free, acquire it by placing an entry in globalMutex
  globalMutex.add(this);
 }
}
origin: iluwatar/java-design-patterns

/**
 * Acquire the globalMutex lock on behalf of current and future concurrent readers. Make sure no writers currently
 * owns the lock.
 */
private void acquireForReaders() {
 // Try to get the globalMutex lock for the first reader
 synchronized (globalMutex) {
  // If the no one get the lock or the lock is locked by reader, just set the reference
  // to the globalMutex to indicate that the lock is locked by Reader.
  while (doesWriterOwnThisLock()) {
   try {
    globalMutex.wait();
   } catch (InterruptedException e) {
    LOGGER.info("InterruptedException while waiting for globalMutex in acquireForReaders", e);
    Thread.currentThread().interrupt();
   }
  }
  globalMutex.add(this);
 }
}
origin: spring-projects/spring-framework

public void doWait() {
  this.counter++;
  // wait until stop is called
  synchronized (this.lock) {
    try {
      this.lock.wait();
    }
    catch (InterruptedException e) {
      // fall through
    }
  }
}
origin: skylot/jadx

  private static boolean test() {
    try {
      synchronized (obj) {
        obj.wait(5);
      }
      return true;
    } catch (InterruptedException e) {
      return false;
    }
  }
}
origin: libgdx/libgdx

void destroy () {
  synchronized (synch) {
    running = false;
    destroy = true;
    while (destroy) {
      try {
        synch.wait();
      } catch (InterruptedException ex) {
        Gdx.app.log(LOG_TAG, "waiting for destroy synchronization failed!");
      }
    }
  }
}
origin: jenkinsci/jenkins

public void waitUntilOffline() throws InterruptedException {
  synchronized (statusChangeLock) {
    while (!isOffline())
      statusChangeLock.wait(1000);
  }
}
origin: libgdx/libgdx

void destroy () {
  synchronized (synch) {
    running = false;
    destroy = true;
    while (destroy) {
      try {
        synch.wait();
      } catch (InterruptedException ex) {
        Gdx.app.log(LOG_TAG, "waiting for destroy synchronization failed!");
      }
    }
  }
}
origin: jenkinsci/jenkins

/**
 * Blocks until the node becomes online/offline.
 */
public void waitUntilOnline() throws InterruptedException {
  synchronized (statusChangeLock) {
    while (!isOnline())
      statusChangeLock.wait(1000);
  }
}
origin: spring-projects/spring-framework

private void executeAndWait(SimpleAsyncTaskExecutor executor, Runnable task, Object monitor) {
  synchronized (monitor) {
    executor.execute(task);
    try {
      monitor.wait();
    }
    catch (InterruptedException ignored) {
    }
  }
}
origin: spring-projects/spring-framework

  public synchronized void waitForCompletion() {
    try {
      wait(WAIT_TIME);
    }
    catch (InterruptedException ex) {
      fail("Didn't finish the async job in " + WAIT_TIME + " milliseconds");
    }
  }
}
origin: apache/incubator-dubbo

@Override
public void doSubscribe(URL url, NotifyListener listener) {
  if (Constants.ANY_VALUE.equals(url.getServiceInterface())) {
    admin = true;
  }
  multicast(Constants.SUBSCRIBE + " " + url.toFullString());
  synchronized (listener) {
    try {
      listener.wait(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
    } catch (InterruptedException e) {
    }
  }
}
origin: apache/incubator-dubbo

@Override
public void doSubscribe(URL url, NotifyListener listener) {
  if (Constants.ANY_VALUE.equals(url.getServiceInterface())) {
    admin = true;
  }
  multicast(Constants.SUBSCRIBE + " " + url.toFullString());
  synchronized (listener) {
    try {
      listener.wait(url.getParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
    } catch (InterruptedException e) {
    }
  }
}
origin: apache/incubator-dubbo

@Override
public void run() {
  try {
    while (!shutdown) {
      synchronized (this) {
        wait(HTTPCLIENTCONNECTIONMANAGER_CLOSEWAITTIME_MS);
        for (PoolingHttpClientConnectionManager connectionManager : connectionManagers) {
          connectionManager.closeExpiredConnections();
          connectionManager.closeIdleConnections(HTTPCLIENTCONNECTIONMANAGER_CLOSEIDLETIME_S, TimeUnit.SECONDS);
        }
      }
    }
  } catch (InterruptedException ex) {
    shutdown();
  }
}
origin: apache/incubator-dubbo

@Override
public void run() {
  try {
    while (!shutdown) {
      synchronized (this) {
        wait(HTTPCLIENTCONNECTIONMANAGER_CLOSEWAITTIME_MS);
        for (PoolingHttpClientConnectionManager connectionManager : connectionManagers) {
          connectionManager.closeExpiredConnections();
          connectionManager.closeIdleConnections(HTTPCLIENTCONNECTIONMANAGER_CLOSEIDLETIME_S, TimeUnit.SECONDS);
        }
      }
    }
  } catch (InterruptedException ex) {
    shutdown();
  }
}
origin: apache/kafka

private synchronized void maybeAwaitWakeup() {
  try {
    int remainingBlockingWakeups = numBlockingWakeups;
    if (remainingBlockingWakeups <= 0)
      return;
    while (numBlockingWakeups == remainingBlockingWakeups)
      wait();
  } catch (InterruptedException e) {
    throw new InterruptException(e);
  }
}
java.langObjectwait

Popular methods of Object

  • getClass
  • toString
  • equals
  • hashCode
  • notifyAll
  • clone
  • <init>
  • notify
  • finalize

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • BoxLayout (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now