Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.4a |
both | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
pthread_t pthread_self(void);
Returns the thread ID of the calling thread.
There are no documented errno values. Use perror() or strerror() to determine the cause of the error.
⁄* CELEBP47 *⁄
#define _OPEN_THREADS
#include <pthread.h>
#include <stdio.h>
pthread_t thid, IPT;
void *thread(void *arg) {
if (pthread_equal(IPT, pthread_self()))
puts("the thread is the IPT...?");
else
puts("the thread is not the IPT");
if (pthread_equal(thid, pthread_self()))
puts("the thread is the one created by the IPT");
else
puts("the thread is not the one created by the IPT...?");
}
main() {
IPT = pthread_self();
if (pthread_create(&thid, NULL, thread, NULL) != 0) {
perror("pthread_create() error");
exit(1);
}
if (pthread_join(thid, NULL) != 0) {
perror("pthread_create() error");
exit(3);
}
}
the thread is not the IPT
the thread is the one created by the IPT