mnguyen
15th December 2004, 02:02 AM
Hi guys,
I'm working on my school project using C/C++ languages. There is a module in which I need to do tasks simultaneously. So I am using the POSIX thread (pthread library) available in the libc.
My problem is : sometimes, i want my thread to suspend an amount of time (say 500ms). The current function I am using is sleep(). However, this function suspends the thread in term of "second" (I remember that the sleep() function of Java works in term of millisecond). Do you know any way to force my thread to suspend in term of milisecond ? (not using a loop since it would keep the CPU busy)
I'm working on my school project using C/C++ languages. There is a module in which I need to do tasks simultaneously. So I am using the POSIX thread (pthread library) available in the libc.
My problem is : sometimes, i want my thread to suspend an amount of time (say 500ms). The current function I am using is sleep(). However, this function suspends the thread in term of "second" (I remember that the sleep() function of Java works in term of millisecond). Do you know any way to force my thread to suspend in term of milisecond ? (not using a loop since it would keep the CPU busy)