Hello,

Im using threads in a recent project. I would like to know whats the difference between:
pthread_kill() and pthread_cancel()

What are the effects of each one?

Thank you!

Recommended Answers

All 2 Replies

Hello,

Im using threads in a recent project. I would like to know whats the difference between:
pthread_kill() and pthread_cancel()

What are the effects of each one?

Thank you!

If your using Linux/Unix try open a terminal and type
man pthread_kill
man pthread_cancel
and it will retrieve all the info you need.

pthread_cancel() : This API used to terminated the another thread, based on cancel ability state the cleanup handlers are called if any handlers are registered before invoking the thread destructor.

pthread_kill() : This API used just like "kill()" API, it raises a signal to thread. It is possible that some times it affects the entire process like when passed SIGKILL to pthread_kill will terminate the entire process.

pthread_kill() can also be used for the activities other than just terminating the thread by passing different signals.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.