Reputation: 77
I am using multiple threads in my program. I want a specific thread to be waken up after 500ms. How can I do that without using a usleep(500)?
Upvotes: 6
Views: 191
Reputation: 52
clock_nanosleep is the POSIX compliant version to sleep for an interval on a high resolution clock, see man page, for example on http://linux.die.net/man/2/clock_nanosleep for details.
Upvotes: 0
Reputation: 91
The socket API like select can be used as a timer.
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 500;
select(0, NULL, NULL, NULL, &tv);
You may need this choice.
Upvotes: 2