sleep

Why an auto scheduled app from Java didn't start on Windows?

霸气de小男生 提交于 2019-12-25 02:09:12
问题 I have a Java Swing app that is supposed to start a 2nd JVM, my code looks like this : public class App_A implements Runnable { ... public static void start2ndJVM() throws Exception { String separator=System.getProperty("file.separator"),classpath=System.getProperty("java.class.path"),path=System.getProperty("java.home")+separator+"bin"+separator+"java"; pb=new ProcessBuilder(path,"-cp",classpath,App_B.class.getName(),"Auto Exit !"); pb.directory(new File("Dir_Data")); File log=new File("Log

Difference between “implicit declaration of function” and the original version of the function

十年热恋 提交于 2019-12-25 01:58:01
问题 I use gcc4.8. And I wrote such code, using sleep. int main(int argc, char *argv[]) { /* I know it's worong to pass a floating number to sleep * this is only for testing. */ sleep(0.001); return 0; } I compile it with "gcc -Wall a.c -o a", got warning "implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration]". Then I ran it, this program sleeps approximately 1 second (it seems sleep ceils 0.001 to 1). Then I change the code to be like this: #include <unistd.h> /* add header

ASynchTask sleep in doinbackground locking the UI thread

我的未来我决定 提交于 2019-12-25 01:45:56
问题 EDIT: SOLVED. Sorry guys, it occurred to me that while my loading of my data was occurring in a background thread, the callback that parsed the data was not. The parsing of the data took a very long time, and that was what was locking my thread. EDIT: It has come to my attention that my overarching problem (the ProgressDialog no longer spinning) may be caused by a problem with my use of a ProgressDialog rather than the UI thread being blocked. If that is the case, how do I fix that? EDIT: to

Thread.sleep() to swing Timer conversion

荒凉一梦 提交于 2019-12-24 17:20:02
问题 I am trying to implement a Thread.sleep(6000) line but it seems to freeze in the applet. When I tried to use Timers, I wasn't sure how to use because I am not very good with event listeners. I am basically trying to call a method fetchUrl() every 6 seconds, after the user clicks the enter button. How can I implement this? public void init() { c = getContentPane(); c.setLayout(flow); c.setBackground(forum); question.setForeground(Color.white); question.setFont(tnr); question2.setForeground

Delaying for milliseconds in C++ cross-platform

↘锁芯ラ 提交于 2019-12-24 16:25:46
问题 I'm writing a multi-platform internal library in C++ that will eventually run on Windows, Linux, MacOS, and an ARM platform, and need a way to sleep for milliseconds at a time. I have an accurate method for doing this on the ARM platform, but I'm not sure how to do this on the other platforms. Is there a way to sleep with millisecond resolution on most platforms or do I have to special-case things for each platform? 回答1: For Linux and Mac OS X you can use usleep : usleep(350 * 1000); For

Php sleep function for delay?

喜你入骨 提交于 2019-12-24 16:09:54
问题 Suppose a website with 'high' traffic, I want to use the php sleep(4) function to avoid flooding. Is it a good idea or should I use different delay ways ? sleep() keeps a connection open, could this be a problem ? I do: index.php -> stuff.php -> index.php Stuff.php does something and then sleep(4); so the user waits 4 seconds with a blank screen, and then goes back to index. Thanks. Update: My enemies are both, hackers, that wants a DOS, and stressed pepole that click fast on the search

Accurate delays between notes when synthesising a song

泄露秘密 提交于 2019-12-24 16:04:32
问题 I'm writing C++ code which plays both digital audio (synthesised music) and MIDI music at the same time (using the RtMidi library.) The digitised music will play out of the computer's audio device, but the MIDI music could play out of an external synthesiser. I want to play a song that uses both digitised instruments and MIDI instruments, and I am not sure of the best way to synchronise these two audio streams: It is not possible to use a function like Sleep() as the delay time is both uneven

Android going to sleep (standby)

不想你离开。 提交于 2019-12-24 14:10:34
问题 I want my android device to go to sleep (screen off), has someone an idea how to do it? In the past I was using the PowerManager function goToSleep(time) , but apparently this function does not exist anymore, I don't understand why. Other topics talk about those lines: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "My wakelook"); wakeLock.acquire(); But it only allows the device to enter sleep mode, without

Thread.Sleep(300) not working correctly

允我心安 提交于 2019-12-24 12:19:39
问题 I want it to execute the first part of the code, then make the pictureBox visible, pause for 3 seconds, hide the pictureBox and execute the rest of the code: // first part of the code here pb_elvisSherlock.Visible = true; Thread.Sleep(300); pb_elvisSherlock.Visible = false; // rest of the code here But it executes the whole block of code and only then pauses. Any ideas what to do? Thanks! 回答1: pb_elvisSherlock.Visible = true; Application.DoEvents(); //let the app show the picturebox Thread

Ignore keyboard input in python while sleeping

╄→гoц情女王★ 提交于 2019-12-24 12:14:05
问题 I'm having a code with a loop asking for some input and then sleeps for some time. The purpose is to prevent for human errors, forcing the user to wait before entering the next input. The problem is, that python does not ignore the keyboard inputs while time.sleep. Here is an example code: from time import sleep from msvcrt import getch for i in range(3): print 'Enter a character' char = getch() sleep(2) print char When pressing some characters consecutively during time.sleep(), msvcrt.getch(