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
71
votes
7 answers

How to wait for all tasks in an ThreadPoolExecutor to finish without shutting down the Executor?

I can't use shutdown() and awaitTermination() because it is possible new tasks will be added to the ThreadPoolExecutor while it is waiting. So I'm looking for a way to wait until the ThreadPoolExecutor has emptied it's queue and finished all of it's…
cottonBallPaws
  • 21,220
  • 37
  • 123
  • 171
67
votes
11 answers

Wait some seconds without blocking UI execution

I would like to wait some seconds between two instruction, but WITHOUT blocking the execution. For example, Thread.Sleep(2000) it is not good, because it blocks execution. The idea is that I call a method and then I wait X seconds (20 for example)…
user3376691
  • 789
  • 1
  • 5
  • 4
66
votes
6 answers

How do I wait until Task is finished in C#?

I want to send a request to a server and process the returned value: private static string Send(int id) { Task responseTask = client.GetAsync("aaaaa"); string result = string.Empty; responseTask.ContinueWith(x =>…
user266003
63
votes
14 answers

Is there a decent wait function in C++?

One of the first things I learned in C++ was that #include int main() { std::cout<<"Hello, World!\n"; return 0; } would simply appear and disappear extremely quickly without pause. To prevent this, I had to go to notepad, and…
user98188
63
votes
5 answers

Delay or Wait-For Statement

I have a 500,000 line SQL script: UPDATE users SET region_id = 9814746 WHERE id = 101 AND region_id IS null; UPDATE users SET region_id = 9814731 WHERE id = 102 AND region_id IS null; UPDATE users SET region_id = 3470676 WHERE id = 103 AND region_id…
sharadov
  • 968
  • 2
  • 13
  • 32
62
votes
5 answers

How to make Selenium wait until an element is present?

I'm trying to make Selenium wait for an element that is dynamically added to the DOM after page load. I tried this: fluentWait.until(ExpectedConditions.presenceOfElement(By.id("elementId")); In case it helps, here is fluentWait: FluentWait…
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
58
votes
11 answers

Concept behind putting wait(),notify() methods in Object class

I am just having hard time to understand concept behind putting wait() in Object class. For this questions sake consider if wait() and notifyAll() are in Thread class. class Reader extends Thread { Calculator c; public Reader(Calculator…
Sunny
  • 2,074
  • 4
  • 24
  • 33
56
votes
8 answers

Why are wait() and notify() declared in Java's Object class?

Why are the wait() and notify() methods declared in the Object class, rather than the Thread class?
Bhupi
  • 2,928
  • 6
  • 34
  • 51
50
votes
9 answers

How can the wait() and notify() methods be called on Objects that are not threads?

How can the wait() and notify() methods be called on Objects that are not Threads? That doesn't really make sense, does it? Surely, it must make sense, however, because the two methods are available for all Java objects. Can someone provide an…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
48
votes
8 answers

How to Wait in Objective-C and Swift

I want to change my UILabel's text after 2 seconds. I tried setting my UILabel's text to "A text", and use sleep(2) and finally changing the text to "Another text". But sleep(2) only freezes the app and "Another text" is set without displaying "A…
jylee
  • 833
  • 2
  • 8
  • 15
48
votes
6 answers

Using wait in AsyncTask

When using a wait in an AsyncTask, I get ERROR/AndroidRuntime(24230): Caused by: java.lang.IllegalMonitorStateException: object not locked by thread before wait() Is it possible to use an Asynctask just for waiting? How? Thanks class WaitSplash…
jul
  • 36,404
  • 64
  • 191
  • 318
48
votes
2 answers

Terminating idle mysql connections

I see a lot of connections are open and remain idle for a long time, say 5 minutes. Is there any solution to terminate / close it from server without restarting the mysql service? I am maintaining a legacy PHP system and can not close the…
shantanuo
  • 31,689
  • 78
  • 245
  • 403
47
votes
5 answers

Wait for kubernetes job to complete on either failure/success using command line

What is the best way to wait for kubernetes job to be complete? I noticed a lot of suggestions to use: kubectl wait --for=condition=complete job/myjob but i think that only works if the job is successful. if it fails, i have to do something…
ruazn2
  • 745
  • 2
  • 8
  • 15
45
votes
7 answers

How to asynchronously wait for x seconds and execute something then?

I know there is Thread.Sleep and System.Windows.Forms.Timer and Monitor.Wait in C# and Windows Forms. I just can't seem to be able to figure out how to wait for X seconds and then do something else - without locking the thread. I have a form with a…
Dennis G
  • 21,405
  • 19
  • 96
  • 133
45
votes
14 answers

How to wait for exit of non-children processes

For child processes, the wait() and waitpid() functions can be used to suspends execution of the current process until a child has exited. But this function can not be used for non-child processes. Is there another function, which can wait for…
CsTamas
  • 4,103
  • 5
  • 31
  • 34