Questions tagged [wait]

In programming, 'wait' refers to the act of pausing the execution of a program until a specific condition is met or a given amount of time has passed.

In programming, 'wait' refers to the act of pausing the execution of a programm until a specific condition is met or a given amount of time has passed.

3454 questions
141
votes
6 answers

Difference between WAIT and BLOCKED thread states

What is the difference between thread state WAIT and thread state BLOCKED? The Thread.State documentation: Blocked A thread that is blocked waiting for a monitor lock is in this state. Waiting A thread that is waiting indefinitely for another…
More Than Five
  • 9,959
  • 21
  • 77
  • 127
123
votes
22 answers

Sleep until a specific time/date

I want my bash script to sleep until a specific time. So, I want a command like "sleep" which takes no interval but an end time and sleeps until then. The "at"-daemon is not a solution, as I need to block a running script until a certain…
theomega
  • 31,591
  • 21
  • 89
  • 127
120
votes
17 answers

wait until all threads finish their work in java

I'm writing an application that has 5 threads that get some information from web simultaneously and fill 5 different fields in a buffer class. I need to validate buffer data and store it in a database when all threads finished their job. How can I…
Ariyan
  • 14,760
  • 31
  • 112
  • 175
118
votes
14 answers

How to wait for a number of threads to complete?

What is a way to simply wait for all threaded process to finish? For example, let's say I have: public class DoSomethingInAThread implements Runnable{ public static void main(String[] args) { for (int n=0; n<1000; n++) { …
DivideByHero
  • 19,715
  • 24
  • 57
  • 64
108
votes
7 answers

Python popen command. Wait until the command is finished

I have a script where I launch with popen a shell command. The problem is that the script doesn't wait until that popen command is finished and go continues right away. om_points = os.popen(command, "w") ..... How can I tell to my Python script to…
michele
  • 26,348
  • 30
  • 111
  • 168
97
votes
8 answers

Kotlin - Wait function

Is there a wait function in kotlin? (I don't mean a Timer Schedule, but actually pause the execution). I have read that you can use Thread.sleep(). However, it doesn't work for me, because the function can't be found.
OhMad
  • 6,871
  • 20
  • 56
  • 85
97
votes
8 answers

How to make the script wait/sleep in a simple way in unity

How can I put a sleep function between the TextUI.text = ...., to wait 3 seconds between each phrase? public Text GuessUI; public Text TextUI; [...truncated...] TextUI.text = "Welcome to Number Wizard!"; TextUI.text = ("The highest number you can…
DiogoSaraiva
  • 1,515
  • 2
  • 15
  • 19
94
votes
9 answers

Java Wait for thread to finish

I have a thread downloading data and I want to wait until the download is finished before I load the data. Is there a standard way of doing this? More Info: I have a Download class that gets data from a URL (Serialized POJOs). Download is Runnable…
Allan
  • 2,889
  • 2
  • 27
  • 38
94
votes
4 answers

How to wait till the response comes from the $http request, in angularjs?

I am using some data which is from a RESTful service in multiple pages. So I am using angular factories for that. So, I required to get the data once from the server, and everytime I am getting the data with that defined service. Just like a global…
anilCSE
  • 2,461
  • 3
  • 23
  • 29
92
votes
7 answers

Waiting for image to load in JavaScript

I'm making an Ajax call which returns me some info including an image path. I prepare all this information in my HTML which will be displayed as a kind of popup. I just toggle the visibility of by popup div from hidden to visible. To set the…
Jeenyus
  • 993
  • 1
  • 6
  • 7
91
votes
10 answers

How can I make a program wait for a variable change in javascript?

I want to force a JavaScript program to wait in some particular points of its execution until a variable has changed. Is there a way to do it? I have already found an extension that is called "narrative JavaScript" that force the program to wait…
Thanasis Petsas
  • 4,378
  • 5
  • 31
  • 57
90
votes
13 answers

How do I create a pause/wait function using Qt?

I'm playing around with Qt, and I want to create a simple pause between two commands. However it won't seem to let me use Sleep(int mili);, and I can't find any obvious wait functions. I am basically just making a console application to test some…
Zac
  • 2,229
  • 9
  • 33
  • 41
81
votes
1 answer

await Task.Delay() vs. Task.Delay().Wait()

In C# I have the following two simple examples: [Test] public void TestWait() { var t = Task.Factory.StartNew(() => { Console.WriteLine("Start"); Task.Delay(5000).Wait(); Console.WriteLine("Done"); }); …
svenskmand
  • 813
  • 1
  • 6
  • 5
79
votes
10 answers

Protractor : How to wait for page complete after click a button?

In a test spec, I need to click a button on a web page, and wait for the new page completely loaded. emailEl.sendKeys('jack'); passwordEl.sendKeys('123pwd'); btnLoginEl.click(); // ...Here need to wait for page complete...…
Zach
  • 5,715
  • 12
  • 47
  • 62
76
votes
4 answers

Java : Does wait() release lock from synchronized block

I was under the impression that wait() releases all locks but I found this post which says "Invoking wait inside a synchronized method is a simple way to acquire the intrinsic lock" Please clarify I'm a bit…
Abhijit
  • 812
  • 1
  • 7
  • 7