sleep

CPU Utilization high for sleeping processes

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 07:09:18
问题 I have a process that appears to be deadlocked: # strace -p 5075 Process 5075 attached - interrupt to quit futex(0x419cf9d0, FUTEX_WAIT, 5095, NULL It is sitting on the "futex" system call, and seems to be indefinitely waiting on a lock. The process is shown to be consuming a large amount of CPU when "top" is run: # top -b -n 1 top - 23:13:18 up 113 days, 4:19, 1 user, load average: 1.69, 1.74, 1.72 Tasks: 269 total, 1 running, 268 sleeping, 0 stopped, 0 zombie Cpu(s): 8.1%us, 0.1%sy, 0.0%ni,

Make a java program sleep without threading

假装没事ソ 提交于 2019-12-21 03:42:32
问题 I have a java program that does some calculations and then uploads the results to a MYSQL database (hosted in another computer in the same network). I sometimes face the problem that the program does calculations faster than it uploads the result. Therefore it is not able to upload all the results. The program currently is not threaded. Is there a way I can make the program sleep for a few milliseconds after it has done the calculations so that the upload takes place properly. (Like in other

Bash sleep in milliseconds

匆匆过客 提交于 2019-12-21 03:23:09
问题 I need a timer which will work with milliseconds. I tried to use sleep 0.1 command in script I see error message: syntax error: invalid arithmetic operator (error token is ".1") When I run sleep 0.1 in terminal it works fine. Please help me! EDIT: Sorry I have take an mistake: function timer { while [[ 0 -ne $SECS ]]; do echo "$SECS.." sleep 0.1 SECS=$[$SECS-0.1] done } Line sleep 0.1 was 5th and SECS=$[$SECS-0.1] was 6th. I just garbled lines. The problem was in 6th line, because bash can't

How to make a thread sleep for specific amount of time in java?

拟墨画扇 提交于 2019-12-20 20:03:13
问题 I have a scenario where i want a thread to sleep for specific amount of time. Code: public void run(){ try{ //do something Thread.sleep(3000); //do something after waking up }catch(InterruptedException e){ // interrupted exception hit before the sleep time is completed.so how do i make my thread sleep for exactly 3 seconds? } } Now how do i handle the case where the thread i am trying to run is hit with an interrupted exception before the complete of the sleep? Also does the thread wake up

Does the method System.currentTimeMillis() really return the current time?

為{幸葍}努か 提交于 2019-12-20 14:19:12
问题 Based on ideas presented in link I implemented several different "sleep methods". One of this methods was the "binary sleep", which looks like this: while (System.currentTimeMillis() < nextTimeStamp) { sleepTime -= (sleepTime / 2); sleep(sleepTime); } Because the check if the next time step is already reached takes place at the beginning I, would expect that the method is running too long. But the cummulative distribution of the simulation error (expected time - real time) looks like this:

Best way to slow down a thread? Is using Sleep() OK?

馋奶兔 提交于 2019-12-20 12:39:08
问题 I've written a C++ library that does some seriously heavy CPU work (all of it math and calculations) and if left to its own devices, will easily consume 100% of all available CPU resources (it's also multithreaded to the number of available logical cores on the machine). As such, I have a callback inside the main calculation loop that software using the library is supposed to call: while(true) { //do math here callback(percent_complete); } In the callback, the client calls Sleep(x) to slow

increasing time delay for login to stop bruteforcing, good idea?

我的梦境 提交于 2019-12-20 10:34:39
问题 I have set up my db to log every failed login attempt. I thought I would multiply the number of failed attempts with 0.05 seconds or something. Something like: time_nanosleep(0, (50000000 * $failed_attempts ) ); More attempts a hacker uses to guess a password, more time does it take to check every time. After checking a 100 passords he must wait 5 sec between each try. Is this a good way to stop bruteforcing? I identify the users by IP. So I guess you can bruteforce the application by using

How to sleep for few milliseconds in swift 2.2?

自作多情 提交于 2019-12-20 10:17:25
问题 please anyone tell me how to use sleep() for few milliseconds in swift 2.2? while (true){ print("sleep for 0.002 seconds.") sleep(0.002) // not working } but while (true){ print("sleep for 2 seconds.") sleep(2) // working } it is working. 回答1: usleep() takes millionths of a second usleep(1000000) //will sleep for 1 second usleep(2000) //will sleep for .002 seconds OR let ms = 1000 usleep(useconds_t(2 * ms)) //will sleep for 2 milliseconds (.002 seconds) OR let second: Double = 1000000 usleep

powershell mouse move does not prevent idle mode

南楼画角 提交于 2019-12-20 09:01:58
问题 Before I start, here is my very first little code I wrote in PowerShell :) [System.Windows.Forms.Cursor]::Position = ` New-Object System.Drawing.Point($pos.X, ($pos.Y - 1)) [System.Windows.Forms.Cursor]::Position = ` New-Object System.Drawing.Point($pos.X, $pos.Y) What do I want to achieve? Well, I want to move the mouse cursor every 4 minutes to prevent the screensaver from appearing (every second in the code above for testing). The code does really move the mouse every time one pixel up and

Dim iPhone Screen, but don't let it sleep

…衆ロ難τιáo~ 提交于 2019-12-20 08:57:52
问题 Update https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScreen_Class/index.html#//apple_ref/occ/instp/UIScreen/brightness That's the Apple Doc for controlling screen brightness. Below is the original question. I have found by using Google that I can disable the iPhone going to sleep in an application by using: application.idleTimerDisabled = YES; so the code looks like this: - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for