About 19,500,000 results
Open links in new tab
  1. wait - How do I make a delay in Java? - Stack Overflow

    public static void wait(int ms) { try { Thread.sleep(ms); } catch(InterruptedException ex) { Thread.currentThread().interrupt(); } } and, then you can call this method anywhere like: wait(1000);

  2. wait() Method in Java With Examples - GeeksforGeeks

    Jun 6, 2021 · Inter-Thread communication is a way by which synchronized threads can communicate with each other using the methods namely wait (), notify () and notifyAll (). wait () method is a part of java.lang.Object class.

  3. wait and notify() Methods in Java | Baeldung

    Jan 8, 2024 · Simply put, calling wait() forces the current thread to wait until some other thread invokes notify() or notifyAll() on the same object. For this, the current thread must own the object’s monitor .

  4. Best way to wait in Java - Stack Overflow

    Feb 23, 2012 · What is the most efficient way to wait until my request is finished being processed by the server? Here's some pseudocode: public void requestData(); public void receiveData(String field, int value); //store data fields and their respective values. public Hashtable<String, Integer> myData; . //implement required ServerDeliveryMethods.

  5. 4 Ways to Add Delay in Java - The Java Programmer

    So we use wait when we want a particular thread to wait for the execution till informed. Like wait(), we have a method notify() and notifyAll(), these methods are called after wait() method. We need to make sure that we call the wait() method only from the synchronized block.

  6. How to Delay Code Execution in Java - Baeldung

    Mar 26, 2025 · It is relatively common for Java programs to add a delay or pause in their operation. This can be useful for task pacing or to pause execution until another task completes. This tutorial will describe two ways to implement delays in Java.

  7. A simple scenario using wait () and notify () in java

    Mar 29, 2010 · The first thing you have to do is to identify the conditions that you want the methods to wait for. In this case, you will want the put() method to block until there is free space in the store, and you will want the take() method to block until there is some element to return. private Queue<T> queue = new LinkedList<T>(); private int capacity;

  8. Wait() Method in Java - CodeGym

    Feb 7, 2025 · In this article, we'll look at the wait () method to control thread, and the notify () / notifyAll () methods. These methods are defined in the base class java.lang.Object and, accordingly, the inheritance mechanisms that are in Java provide these methods to …

  9. How to Add delay in Java for sometime? - JavaProgramTo.com

    Aug 5, 2020 · In this article, You'll learn how to delay the code execution for some seconds or minutes in java. This quite simple and easy to force the code to sleep or pause for some time and do the remaining execution or waiting for another task to complete.

  10. Wait() Method in Java & How Wait() Method Works - JavaGoal

    Mar 25, 2020 · The wait() method is defined in the Object class which is the super most class in Java. This method tells the calling thread (Current thread) to give up the lock and go to sleep until some other thread enters the same monitor and calls notify() or notifyAll().

  11. Some results have been removed
Refresh