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)?
sleep(time): This is a method used to sleep the thread for some milliseconds time. suspend(): This is a method used to suspend the thread.
Java Thread suspend() method The suspend() method of thread class puts the thread from running to waiting state. This method is used if you want to stop the thread execution and start it again when a certain event occurs. This method allows a thread to temporarily cease execution.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With