开发者

Cancelling a Blocked Pthread

How do I cause a thread to respond to pthread_cancel开发者_如何学JAVA() if it is blocked on a sem_wait()?


You can set a signal handler, let's says for SIGUSR1, for the thread that will be blocking then, from another thread, you call pthread_cancel(tid) and pthread_kill(tid, SIGUSR1). The thread will be canceled once sem_wait() is interrupted by the signal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜