wait

ProcessBuilder and Process.waitFor(), how long does ist wait?

白昼怎懂夜的黑 提交于 2019-11-30 08:59:30
问题 I am executing an .exe-file from java, using the ProcessBuilder class and the Process class. To explain what I am doing: builder = new ProcessBuilder(commands); builder.redirectErrorStream(true); Process process = builder.start(); process.waitFor(); I just wanted to know, for how long is "waitFor()" waiting? Is it waiting until my .exe is executed, or is it waiting till its execution is finished? My .exe is a compiled AutoIt-script. That means, that there could be interactions like mouse

Java: How can a thread wait on multiple objects?

跟風遠走 提交于 2019-11-30 08:12:56
A thread can use Object.wait() to block until another thread calls notify() or notifyAll() on that object. But what if a thread wants to wait until one of multiple objects is signaled? For example, my thread must wait until either a) bytes become available to read from an InputStream or b) an item is added to an ArrayList . How can the thread wait for either of these events to occur? EDIT This question deals with waiting for multiple threads to complete -- my case involves a thread waiting for one of many objects to be singnaled. sgokhales A thread cannot wait on more than one object at a time

Lua - get command line input from user?

隐身守侯 提交于 2019-11-30 07:09:35
问题 In my lua program, i want to stop and ask user for confirmation before proceeding with an operation. I'm not sure how to stop and wait for user input, how can it be done? 回答1: Take a look at the io library, which by default has standard-input as the default input file: http://www.lua.org/pil/21.1.html 回答2: local answer repeat io.write("continue with this operation (y/n)? ") io.flush() answer=io.read() until answer=="y" or answer=="n" 回答3: I've worked with code like this. I will type this in a

Adding a wait-for-element while performing a SplashRequest in python Scrapy

﹥>﹥吖頭↗ 提交于 2019-11-30 07:01:23
I am trying to scrape a few dynamic websites using Splash for Scrapy in python. However, I see that Splash fails to wait for the complete page to load in certain cases. A brute force way to tackle this problem was to add a large wait time (eg. 5 seconds in the below snippet). However, this is extremely inefficient and still fails to load certain data (sometimes it take longer than 5 seconds to load the content). Is there some sort of a wait-for-element condition that can be put through these requests? yield SplashRequest( url, self.parse, args={'wait': 5}, 'User-Agent':"Mozilla/5.0 (X11; Linux

Checking the status of a child process in C++

妖精的绣舞 提交于 2019-11-30 07:00:21
I have a program that uses fork() to create a child process. I have seen various examples that use wait() to wait for the child process to end before closing, but I am wondering what I can do to simply check if the file process is still running. I basically have an infinite loop and I want to do something like: if(child process has ended) break; How could I go about doing this? Use waitpid() with the WNOHANG option. int status; pid_t result = waitpid(ChildPID, &status, WNOHANG); if (result == 0) { // Child still alive } else if (result == -1) { // Error } else { // Child exited } EDIT: If you

Displaying wait cursor in while backgroundworker is running

爷,独闯天下 提交于 2019-11-30 06:39:51
During the start of my windows application, I have to make a call to a web service to retrieve some default data to load onto my application. During the load of the form, I run a backgroundworker to retrieve this data. I want to display the wait cursor until this data is retrieved. How would I do this? I've tried setting the wait cursor before calling the backgroundworker to run. When I report a progress of 100 then I set it back to the default cursor. The wait cursor comes up but when I move the mouse it disappears. Environment: Windows 7 Pro 64-bit VS2010 C# .NET 4.0 Windows Forms EDIT: I am

How to make C program wait (on Linux)?

喜你入骨 提交于 2019-11-30 05:40:46
问题 How to make C program wait (on Linux)? (I need to use wait with MPI - I need C code please) 回答1: If you want to wait for a MPI request use MPI_Wait: http://www.manpagez.com/man/3/MPI_Wait/ If you want to wait a certain amount of time use sleep: http://www.manpagez.com/man/3/Sleep/ If you want to wait another process to end use waitpid: http://linux.die.net/man/2/waitpid If you want to wait a condition variable (multi-threaded programming) use pthread_cond_wait: http://www.opengroup.org

java中为什么notify()可能会导致死锁,而notifyAll()则不会

走远了吗. 提交于 2019-11-30 03:13:25
简单的说,notify()只唤醒一个正在等待的线程,当该线程执行完以后施放该对象的锁,而没有再次执行notify()方法,则其它正在等待的线程 则一直处于等待状态,不会被唤醒而进入该对象的锁的竞争池,就会发生死锁。 JVM多个线程间的通信是通过 线程的锁、条件语句、以及wait()、notify()/notifyAll组成。 下面来实现一个启用多个线程来循环的输出两个不同的语句: package com.tyxh.block; class OutTurn { private boolean isSub = true; private int count = 0; public synchronized void sub() { try { while (!isSub ) { this.wait(); } System. out .println("sub ---- " + count); isSub = false ; this.notify(); } catch (Exception e) { e.printStackTrace(); } count++; } public synchronized void main() { try { while (isSub ) { this.wait(); } System. out .println("main ((((((((((((

jQuery Wait until async ajax calls are finished

依然范特西╮ 提交于 2019-11-30 02:45:50
问题 Hi I have 2 ajax calls in my script, I need them run asnyc to spare time, but I need the second to wait until the first is finished. $.ajax({ type: "POST", url: "getText.asmx/ws_getText", data: parO1, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert(msg.d.data); } , error: function () { chyba("chyba v požadavku", "df"); } }); if (parO2.length > 0) { $.ajax({ type: "POST", url: "getText.asmx/ws_getText", data: parO2, contentType: "application

Why do all Java Objects have wait() and notify() and does this cause a performance hit?

让人想犯罪 __ 提交于 2019-11-30 01:03:58
Every Java Object has the methods wait() and notify() (and additional variants). I have never used these and I suspect many others haven't. Why are these so fundamental that every object has to have them and is there a performance hit in having them (presumably some state is stored in them)? EDIT to emphasize the question. If I have a List<Double> with 100,000 elements then every Double has these methods as it is extended from Object . But it seems unlikely that all of these have to know about the threads that manage the List . EDIT excellent and useful answers. @Jon has a very good blog post