PDA

Visualizza la versione completa : [c/pthread]Thread's number id


pistilloi
15-12-2013, 13:39
normale che il numero identificativo dei threads sia negativo?


#include<stdio.h>#include<stdlib.h>
#include<pthread.h>


void *thread_function();


int main() {


pthread_t thread;

if( 0 != pthread_create(&thread, NULL, thread_function, NULL) )
{
perror("impossible thread creation");
exit(1);
}


pthread_join(thread, NULL);
return 0;
}


void *thread_function() {

printf("thread number = %ld\n", pthread_self());
}


$ cc -pthread athread.c$ ./a.out
thread number = -1218548928
$

Loading