为什么start_routine for pthread_create返回void *并取无效*

pthread_create的函数头如下所示:

 int pthread_create(pthread_t * thread, const pthread_attr_t * attr, void * (*start_routine)(void *), void *arg); 

我理解这一切除了start_routine的函数指针的forms为void* (*fpointer) (void*) ,这意味着它接受一个void指针并返回一个void指针

它所采用的void指针只是一种将参数传递给start_routine的方法,我得到了那个部分,但是我不明白为什么函数会返回一个void指针? 什么代码甚至会注意到void指针?

从pthread_create的文档:

创建线程执行start_routine,arg作为唯一参数。 如果start_routine返回,则效果就像是使用start_routine的返回值作为退出状态对pthread_exit()进行隐式调用。 请注意,最初调用main()的线程与此不同。 当它从main()返回时,效果就好像使用main()的返回值作为退出状态对exit()进行了隐式调用。

和pthread_exit :

pthread_exit()函数终止调用线程,并使值value_ptr可用于与终止线程的任何成功连接。

因此,如果在线程上执行pthread_join,它返回的指针将传递回连接线程,允许您将信息从垂死线程传输到另一个活动线程。

从规格 :

如果start_routine返回,则效果就像是使用start_routine的返回值作为退出状态对pthread_exit()进行隐式调用。