开发者

Cancelling a Blocked Pthread

开发者 https://www.devze.com 2023-01-21 04:18 出处:网络
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 the

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

精彩评论

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