sleep is a system call that suspends a process or thread for a specified amount of time
Questions tagged [sleep]
3187 questions
1
vote
1 answer
Perl: Sleep for x seconds unless keypress
In perl is there a way to have a program sleep for a certain amount of time unless the user presses a key? The following is my code:
use Term::ReadKey;
ReadMode 4;
while (not defined ($key = ReadKey(-1))) {
sleep(50);
}
print "Get key…

Bijan
- 7,737
- 18
- 89
- 149
1
vote
2 answers
get the number of seconds left for the sleep command to end in a shell script
I built a shell script that sleeps for a specified amount of minutes and shows notification when it is done.
TIME=$(zenity --scale --title="Next Session in (?) minutes")
sleep…

Merhawi Fissehaye
- 2,482
- 2
- 25
- 39
1
vote
1 answer
Random Numbers in For Loops
Hi I have searched all over the internet for this answer and please let me explain before i get into the actual problem. it may seem simple to but the only choices that really helped me was Thread.Sleep and Thread.SpinWait but it basically stops my…

Green Bray Games LLC
- 19
- 6
1
vote
0 answers
Java: is wait(timeout) at least as precise as sleep(timeout) in suspending for timeout millisecs?
(Duplication: there are a lot of questions about wait() vs sleep(), but I need this specific detail, which I haven't found addressed in any on the answers.)
Context:
I have a scheduler implemented with sleep(), but I want to change its…

GozzoMan
- 782
- 9
- 23
1
vote
3 answers
Is Thread.sleep(n) blocking other things from going? Something better to replace it?
I have a little application counting time by pressing a button,
I just use thread.sleep() to count.
When the button is pressed, it triggers the ActionListener which is a class that perform a thread.run(). The thread.sleep() is then started from…

伍柒貳
- 49
- 1
- 1
- 6
1
vote
2 answers
how to make a counter in linux?
I'm trying to write a script where I want to make a countdown of three seconds (probably with the sleep command), but every second I want to display the text "break".
After every second, I want to display a countdown next to the word "break", but…

Jim Peeters
- 2,573
- 9
- 31
- 53
1
vote
1 answer
sleep method doesn't working if i call second time?
Here i am actually trying to do a simple animation. A circle will getting smaller and smaller with a particular speed. I used sleep method to set interval between each time of reducing the radius of the circle. I gave five seconds for sleep method.…

Ganesh
- 1,820
- 2
- 20
- 40
1
vote
1 answer
Scheduling in Ruby on Rails and stopping sleep method
I want to schedule an execution for every 30 mins in Ruby on Rails. I know sleep can be used. Is there any other efficient method?
Note that Cron jobs, "whenever" gems won't be helpful since I dont want it as a job just a part of execution. And once…

Daniel Sagayaraj
- 177
- 2
- 20
1
vote
2 answers
Java multi-threading scope of Thread.sleep
According to Oracle's documentation for Thread.sleep:
Thread.sleep causes the current thread to suspend execution for a specified period.
I am wondering what is considered the current thread.
I have a simple interface called Function:
public…

NateisStalling
- 73
- 1
- 4
1
vote
2 answers
Wait for a time frame in Java: how does Thread.sleep(int) work?
Conventionally, I delay my programs for a short time with Thread.sleep(int) surrounded with an e.printStackTrace() try/catch block. I want to do away with the exception handling. I wrote this function:
private static void pause(int millis) {
…

Scruffy
- 580
- 8
- 23
1
vote
2 answers
Computer does not stay awake after scheduled task
I have a scheduled task that wakes up the computer to run a batch file. However the computer turns back off after some time. I have my computer set to (never sleep) so after waking up from the task it should stay on.
However after doing some reading…

user3093979
- 11
- 2
1
vote
2 answers
Is it ok to use sleep() in a loop to be nice?
I couldn't describe the question better.
this is from redis-py github page.
>>> while True:
>>> message = p.get_message()
>>> if message:
>>> # do something with the message
>>> time.sleep(0.001) # be nice to the system :)
I…

eugene
- 39,839
- 68
- 255
- 489
1
vote
1 answer
Update a buttons UIImage while a counter decreases iOS
I am trying to change a UIButton's UIImage every second, until a counter reaches 0. I have tried NSTimer, performSelector withDelay but I could not get either of those to work, plenty of googling came up with different options but pointed to the…

guytz72
- 419
- 2
- 14
1
vote
3 answers
JFrame: Sleep between statements
I'm still very new to the world of programming and have recently noticed, that whenever I tell the programm to idle for some seconds between the code, it instead sleeps at the start and then goes through the remaining code.
I've tried various ways…

CrazyBacon
- 55
- 2
- 8
1
vote
4 answers
Terminate an unresponsive/infinite-looping WebWorker (Javascript)
I am writing a language for educational purpose, which should run in web browsers. The language compiles to JavaScript.
So there is the problem of endless loops and recursion.
Until that moment I thought the solution would be to have the runtime…

user3025619
- 7
- 1