In c, we create a thread like so:
void * run(void * arg){
printf("hello world\n");
}
int main(){
pthread_t thread;
int a = pthread_create(&thread, NULL, run, (void*)0);
}
But it will not work if I declare run as
void run(){}
On the other hand, if I cast it to (void *) in the parameter of pthread_create, it works fine. So it only accepts functions with return types of (void *).
Why?
Thanks !
On my system,
man pthread_createsays:This return value is available through the
pthread_join()function: