Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wakeup sleeping thread

I'm using the nanosleep function in a multithreaded program. I'm having nanosleep act as a timer that should be able to be interrupted by another thread if a certain condition passes. I found on a website someone ask a similar question, and they said you can't wakeup from a sleep: http://www.codeguru.com/forum/archive/index.php/t-431651.html

Is this true, or is it just with WinAPI (I'm programming in a UNIX environment)?

like image 702
Pavlov's Kitten Avatar asked Sep 25 '26 04:09

Pavlov's Kitten


1 Answers

If you want to do this, why not just use a timed wait on a condvar?

like image 176
Robert Allan Hennigan Leahy Avatar answered Sep 26 '26 18:09

Robert Allan Hennigan Leahy