Name

pthread_equal
- compare thread IDs

Library

libc_r.lib libpthread.lib libthr.lib

Synopsis

  #include <pthread.h>
  int pthread_equal (pthread_t t1, pthread_t t2);

Return values

The pthread_equal function will return non-zero if the thread IDs t1 and t2 correspond to the same thread, otherwise it will return zero.

Detailed description

The pthread_equal function compares the thread IDs t1 and t2.

Examples

void *a_thread_func_1_2(void*)
{
 pthread_exit(0);
 return NULL;
}
void XYZ()
{
pthread_t new_th1, new_th2;
 /* Create a new thread. */
 if(pthread_create(&new_th1, NULL, a_thread_func_1_2, NULL) != 0)
 {
  perror("Error creating thread\n");
  return -1;
 }
 /* Create another new thread. */
 if(pthread_create(&new_th2, NULL, a_thread_func_1_2, NULL) != 0)
 {
  perror("Error creating thread\n");
  return -1;
 }
 /* Call pthread_equal() and pass to it the 2 new threads.
  * It should return a zero value, indicating that
  * they are not equal. */
 if(pthread_equal(new_th1, new_th2) != 0)
 {
  printf("pthread_equal FAILED\n");
  return -1;
 }
}

         

Errors

None.

See also

pthread_create, pthread_exit


Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top