首页 > 解决方案 > 使用 pthread_exit 终止线程,然后返回 - 奇怪的例子

问题描述

我找到了这个例子;这里两个线程 threadDefault 和 threadCustomized 通过使用 pthread_exit 然后返回来终止。为什么作者写了这两个指令?

标签: cmultithreadingreturnpthreadspthread-exit

解决方案


Mohith Reddy 的回答是正确的,但没有抓住重点。当然,return 语句永远不会执行,因为pthread_exit它不会返回,但它会抑制来自编译器的警告,以防它不知道pthread_exit不会返回。


推荐阅读