[問題] pthread 停止問題

看板C_and_CPP (C/C++)作者 (Maiko)時間11年前 (2015/04/22 03:46), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) GCC 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) pthread 問題(Question): 是這樣的 我目前程式 main 會處理大部份的事情 但因某種需求要特別處理 所以我多開一條 thread 來做 我使用 linux pthread pthread_create function 來建一條 thread 因為這 thread 裡有 while(1) 我希望當這thread 有某個情況能停止掉這thread 所以我該如何停止住thread 才是對的呢? google 一下是該在這個thread 裡面使用 pthread_exit(0)?? 那如果要再重啟同樣的thread 是要呼叫一次pthread_create?? 抱歉 我是程式新手 剛測試一下是OK的 但想了解正確的做法 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.70.202.53 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1429645565.A.4B7.html

04/23 20:56, , 1F
可以貼source code嗎
04/23 20:56, 1F

04/24 14:07, , 2F
你要停止還是暫停?
04/24 14:07, 2F

04/29 14:12, , 3F
pthread_cancel 之類的吧
04/29 14:12, 3F
文章代碼(AID): #1LDgZzIt (C_and_CPP)
文章代碼(AID): #1LDgZzIt (C_and_CPP)