usage of pthread_create() header file : #include <pthread.h>, lib to link : libpthread.a, should add parameter -lpthread when compiling, but I found it's also ok if not adding it. Perhaps crash when running.
use it in C: thread function declaration: void thread_fun(void); pthread_t threadId; use it like that is ok
use it in C++: thread function declaration: void* thread_fun(void* param); pthread_t threadId;
note: function must be like void* thread_fun(void* param), else compiler will report error : invalid conversion from ‘void*’ to ‘void* (*)(void*) |