- A thread library provides the programmer an API for creating and managing threads. There are two primary ways of implementing a thread library.
- The first approach is to provide a library entirely in user space with no kernel support. All code and data structures for the library exist in user space. This means that invoking a function in the library results in a local function call in user space and not a system call.
- The second approach is to implement a kernel-level library supported directly by the OS. In this case, code and data structures for the library exist in kernel space. Invoking a function in the API for the library typically results in a system call to the kernel.
- Three main thread libraries are in use today:
- POSIX Pthreads. Pthreads, the threads extension of the POSIX standard, may be provided as either a user- or kernel-level library.
- Win32. The Win32 thread library is a kernel-level library available on Windows systems.
- Java. The Java thread API allows thread creation and management directly in Java programs. However, because in most instances the JVM is running on top of a host OS, the Java thread API is typically implemented using a thread library available on the host system.