举例UNIX International 线程
UNIX International 线程的头文件是<thread.h> [1] ,仅适用于Sun Solaris操作系统。所以UNIX International线程也常被俗称为Solaris线程。
1.创建线程
intthr_create(void*stack_base,size_tstack_size,void*(*start_routine)(void*),void*arg,longflags,thread_t*new_thr);
2.等待线程
intthr_join(thread_twait_for,thread_t*dead,void**status);
3.挂起线程
intthr_suspend(thread_tthr);
4.继续线程
intthr_continue(thread_tthr);
5.退出线程
voidthr_exit(void*status);
6.返回当前线程的线程标识符
thread_tthr_self(void);POSIX线程
POSIX线程(Pthreads)的头文件是<pthread.h>,适用于类Unix操作系统。Windows操作系统并没有对POSIX线程提供原生的支持库。不过Win32的POSIX线程库的一些实现也还是有的,例如pthreads-w32 [2] 。
1.创建线程
intpthread_create(pthread_t*thread,constpthread_attr_t*attr,void*(*start_routine)(void*),void*arg);
2.等待线程
intpthread_join(pthread_tthread,void**retval);
3.退出线程
voidpthread_exit(void*retval);
4.返回当前线程的线程标识符
pthread_tpthread_self(void);
5.线程取消
intpthread_cancel(pthread_tthread);Win32线程