When you program with POSIX Threads API, there is one thing about pthread_exit() that you may ignore for mistake. In subroutines that complete normally, there is nothing special you have to do unless you want to pass a return code back using pthread_exit(). The completion won't affect the other threads which were created by the main thread of this subroutine. However, in main(), when the code has been executed to the end, there could leave a choice for you. If you want to kill all the threads that main() created before, you can dispense with calling any functions. But if you want to keep the process and all the other threads except for the main thread alive after the exit of main(), then you can call pthread_exit() to realize it. And any files opened inside the main thread will remain open after its termination.
Use pthread_exit() To Terminate main() With The Other Threads Alive
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
Parallel program running in dual-core environment
yxzzy_young
2020-06-20 09:19:35
Java面試問題之五十六
[百度面試問題之三]:請談談你對Java垃圾收集器中並行和併發概念的理解。答:並行和併發這兩個概念都是編程中的概念,在垃圾收集器的上下文語境中,我們應
iteye_16074
2020-06-16 14:48:26
Communications of Processes and Threads
yxzzy_young
2020-02-25 18:59:38
Three Methods to Parallel Programming Decomposition
yxzzy_young
2020-02-25 18:59:37
CPU Identification
yxzzy_young
2020-02-25 18:59:36
Principles of parallel programming
lllcfr1
2020-02-20 22:20:33
SCI收錄的計算機科學 - 理論與方法類 - 期刊目錄
jkxsanger
2020-07-08 01:36:18
【我所認知的BIOS】->反彙編BIOS之Bootblock(4)
lightseed
2020-07-06 00:39:09
Volume Rendering using CUDA – Basic framework
saintony
2020-07-05 08:40:52
縮略語手冊(A-G)
Direwolf
2020-07-03 01:43:09
電子元器件廠商網站大全
Acctel Technologies http://www.acceltech.comActel Corp. http://www.actel.comAldec Inc. htt
wind_wolf00
2020-07-03 01:13:48
Factory method pattern(air: different from the abstract one)
autoair
2020-07-02 20:00:49
大數據時代,我們需要有超越 Hadoop和MapReduce的殺手級技術
miller_lover
2020-07-02 17:43:34
計算機領域的頂級會議和期刊
Garfield2005
2020-07-01 22:17:35
24小時熱門文章