Multithreaded Programming Guide

Including <thread.h> or <pthread.h>

The include file <thread.h> contains declarations for the Solaris threads functions. To call any Solaris thread functions, your program needs to include <thread.h>. This file enables you to produce compiled code that is compatible with earlier releases of the Solaris software.

The include file <pthread.h> contains declarations for the Pthreads functions and is required if your program uses Pthreads.

You can mix Solaris threads and POSIX threads in the same application by including both <thread.h> and <pthread.h> in the application. Then when linking and compiling you need to specify the -lpthread flag to link in the pthread APIs.

When using -mt, the Solaris threads APIs will be linked automatically. Always use the -mt option instead of listing -lthread explicitly. To use Pthreads, specify the -mt option and -lpthread option on the link command line. The libpthread library provides an interface to libthread, so you still need libthread when using Pthreads.