pthread_self does not return a numeric type, but an opaque type pthread_t (which may be an opaque struct ).
I suggest you clear the array with
memset(id, 0, sizeof(id));
Indeed, in GNU / Linux / Debian / Sid / x86-64, the internal include /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h file has
typedef unsigned long int pthread_t;
But I donβt think you should believe that this is a thread identification, just an opaque descriptor (like file descriptors).
I suggest you read a good pthreads tutorial, for example, for example. this blaze barney
Currently, threads of multi-core machines [can] work differently on different cores.
source share