void
对于该函数,函数参数是void (*routine)(void *),则可以创建下面这个函数来对应。
void pthread_cleanup_push(void (*routine)(void *), void *arg);
static void cleanup(void *arg)
{
printf("cleanup: %s\n", (char *)arg);
}
且由于是void类型所以该函数没有返回值。
调用方法:
pthread_cleanup_push(cleanup, "第 1 次调用");
Void *
对于该线程创建函数
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
以参数代码void *(*start_routine) (void *)为例,该参数创建函数为
static void *new_thread_start(void *arg)
{
printf("新线程: 进程 ID<%d> 线程 ID<%lu>\n", getpid(), pthread_self());
return (void *)0;
}
返回值为void *类型即可。
使用方法
ret = pthread_create(&tid, NULL, new_thread_start, NULL);