Questions tagged [sleep]

sleep is a system call that suspends a process or thread for a specified amount of time

3187 questions
1
vote
2 answers

What to use pthread_join,pthread_exit or pthread_cancel while thread in sleep and need to close gracefully?

I have a thread running in while with condition and it has sleep of 2 minutes. (i.e. while (condition) { //do something sleep(120); } ) To terminate the thread gracefully, I used pthread_join() and made while condition to false (e.g.…
shah_pankil
  • 41
  • 1
  • 1
  • 5
1
vote
2 answers

sleep for many days with resolution of microseconds

Is there a way to put a thread to sleep for many days with a resolution of microseconds? usleep can only put the thread to sleep for 1000000 and sleep works in second steps. Is there a way to, may be, use both sleep and usleep to achieve this?
lies
  • 31
  • 2
1
vote
2 answers

Axis2, using Thread.sleep to do blocking

I am currently coding a Java WebService using axis2. However, one particular request needs me to do constant polling a status in another server for around 3-10 seconds time. I want to use Thread.sleep to do polling like every 500 mili for 3…
henry
  • 969
  • 2
  • 11
  • 21
1
vote
1 answer

Printing array elements in one second intervals using sleep()

I have an array that contains chars. I am trying to print out an element once every second. int i=0; while (i< 110) { cout << arrayValue[i]<<"\0"; sleep(1); i++; } This for some reason just waits for 110 seconds and than prints out…
obsi
  • 53
  • 1
  • 8
1
vote
1 answer

Sleeping a Thread until certain time in Python

I've written a script that creates threads which sleep themselves until a certain time of day before sending an email. Some run at 4pm on the day the script is run, others run at 7am the next morning. My problem is that the threads that are supposed…
Tom Sitter
  • 1,082
  • 1
  • 10
  • 23
1
vote
0 answers

Alternative to the sleep command in PHP

I want to display the position of a selection of boats on a page using Google Maps and PHP. To receive position data I use the Winlink API, where for a specific boat (by callsign) the position data is returned via RSS. Once per day, a cron-job runs…
mischa.mole
  • 357
  • 2
  • 12
1
vote
2 answers

How to start counting time at the start of my program in C

I'm making a game in which you must hack a system like: type numbers you see on the screen: 12345 in 10 seconds. I wonder how to warn a player when 10 seconds elapse, like print on the screen "Too slow!!!!!!". I tried sleep() function, but it stops…
Alenprintf
  • 143
  • 1
  • 7
1
vote
1 answer

perl par-packer exe file sleep() not working

hello.pl is a file which works fine: print "Hello World"; sleep(5); When I convert that to hello.exe using par-packer, window will sleep for 5 sec but won't print "Hello World" - which is actually printed after 5 sec and window exits. Any solution…
SSh
  • 179
  • 2
  • 13
1
vote
2 answers

How to have simultaneous setLocation and setText in JLabel?

In the try block of my code either of setText() or setLocation() are working well separately as explained below: Following code move the label in right way (each time 50 pxl) according to given sleep: ......... …
Jit
  • 131
  • 4
1
vote
0 answers

PowerPoint VBA - some pieces of code runs not in order (MsgBox, Sleep etc)

VBA - 7.1. PowerPoint 2013 I am trying to achieve a small animation for an image on a slide (hide - wait half a sec - show). I had noticed earlier that MsgBox usually pops up before the previous line of code gets completely executed. While it was…
Arun K
  • 25
  • 1
  • 7
1
vote
1 answer

iPhone: Force UIButton to redraw itself

I got 5 UIButtons placed next to each other and what I wanna do is set image on first button, redraw it so it, wait for 1 second, then set some other image on second button, redraw second button and so on. I tried to set image on button, then call…
1
vote
1 answer

iPhone App: How do I call a function after my iPhone has been to sleep?

I have an app with some animations which are called by timers. When one animation finishes then a timer is called to start another. If the iPhone sleeps and requires unlocking to activate it then the animations do not start. This is obviously…
user157733
  • 569
  • 2
  • 12
  • 26
1
vote
1 answer

Execution time limit exceeded with PHP random number generator

I'm trying to make a program that prints a random number every 3 seconds, but my mistake is "Maximum execution time of 30 seconds exceeded", sorry but I have almost no experience in PHP and I know the functions to clear the memory, I appreciate your…
Diana Pérez
  • 101
  • 8
1
vote
1 answer

How to keep track of time in python without sleeping?

I'm wondering how I can play a .wav file after some time has passed without using the sleep function. Essentially, I was wondering if there is a way to keep track of time in Python, so that, after say 15 seconds has elapsed, I can play a sound…
Nick Folz
  • 93
  • 1
  • 7
1
vote
1 answer

Will process lost wake-up chance in a preemptive kernel?

Usually, when processes want to wait some events that are not available, we can put them into sleep and wake up them later when the events occur. The familiar codes below fulfil this task: while (!events) { DEFINE_WAIT(wait); …
Douglas Su
  • 3,214
  • 7
  • 29
  • 58