lllook
lllook

Reputation: 749

Exit pthread that is executing

How do I self-terminate pthread execution?

I have this code

while(1)
{
  if(...)
  {
    terminate
  }
  work();
}

I have to use pthread_exit(); but what do I give as parameter?

Upvotes: 0

Views: 400

Answers (1)

According to the manuals

The pthread_exit() function terminates the calling thread and returns a value via retval that (if the thread is joinable) is available to another thread in the same process that calls pthread_join(3).

This is any value you want to provide to the joining thread. If you do not need a return value, you can pass NULL.

Upvotes: 2

Related Questions