[问题] 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