I need to create a thread, and have do some processing then sleep for certain time, then wake up do more processing,etc.
I'm used to Java programming and this would be super easy. Is there an easy way to implent this in anis C. thanks!!
I need to create a thread, and have do some processing then sleep for certain time, then wake up do more processing,etc.
I'm used to Java programming and this would be super easy. Is there an easy way to implent this in anis C. thanks!!
No. C has no concept of threading. You'll have to look at OS-specific functions for that.
On UNIX-like systems you can use POSIX threads, which means you're portable to a number of different operating systems.
Using the Win32 API:
-Create a function with a return type of VOID or DWORD WINAPI
-The function's parameter must be the type of LPVOID or void*
-Make a call to CreateThread() while passing the function into the 3rd parameter
Ex:
Code:CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&my_thread, NULL, 0, 0);