標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
POSIX.4a |
両方 | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
pthread_t pthread_self(void);
呼び出しスレッドのスレッド ID を戻します。
設定される errno 値はありません。 perror() または strerror() を使用して、エラーの原因を判別してください。
⁄* 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