首页 > 代码库 > Thread ID vs Pthread Handle(pthread_t)
Thread ID vs Pthread Handle(pthread_t)
在很多线程实现的案例中,pthread_t作为抽象类型,被指定为长度为4的整行作为线程ID。
在一些iSeries服务器的线程实现上,线程ID是一个64位的整型数值和pthread_t是一个抽象
的结构体包含数值和一些其他的参数。抽象化允许进程容纳上千个线程。
如果不允许移植,不允许进程访问pthread_t的内部数据和尺寸,例如对比线程ID,对于可移植的对比,
使用pthread_equal函数。文档通常描述pthread_t作为线程句柄,避免因为使用一个整型表示线程ID
而混淆概念,
Thread ID vs. Pthread Handle (pthread_t)
In many threads implementations, thepthread_t abstract type is implemented as an integer (4 byte) thread ID.
In the iSeries implementation of Pthreads,the thread ID is a 64-bit integral value and the pthread_t is an
abstraction (structure) that contains thatvalue and others.This abstraction helps to allow the implementation
toscale to thousands of threads in a process.
Do not allow your program to rely on theinternal structure or size of the pthread_t in a non-portable fashion,
suchas comparisons of thread IDs. For portable comparison, use the pthread_equal()API. This documentation
occasionally refers to the pthread_t as aPthread handle to try to prevent the misconception that
it represents a single integer value.
Thread ID vs Pthread Handle(pthread_t)