[問題] pthread 停止問題

作者: gamed (Maiko)   2015-04-22 03:46:02
開發平台(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的
但想了解正確的做法
謝謝
作者: pili100 (zelda)   2015-04-23 20:56:00
可以貼source code嗎
作者: noonOut (中午外出)   2015-04-24 14:07:00
你要停止還是暫停?
作者: jynyptt (Jyny)   2015-04-29 14:12:00
pthread_cancel 之類的吧

Links booklink

Contact Us: admin [ a t ] ucptt.com