52.1 Thread Types

With LibC, you can create two categories of threads:

The following table describes the types of tasks these thread types can perform.

Thread Type

Description

Joinable

A joinable thread can join with another thread and notify that thread when it has finished its work and, optionally, the status of that work. When an application starts up, LibC creates a joinable thread for the main function of the application.

Detached

A detached thread performs work, but it cannot notify another thread when the work is done.

Daemon

A daemon thread can provide a service to other objects or threads within the application. For example, a daemon thread can be an infinite loop, waiting for a service request such as fetching an image or refreshing the screen.

Anonymous

A detached thread supports the concept of work. An application schedules a task to be performed, and LibC handles the execution of the task. The task can be scheduled to complete once or periodically.

Thread type determines a number of the characteristics of the thread and the scope of its influence. For example, if all joinable and detached threads exit, the application exits. Daemon and anonymous threads do not participate in the decision to exit.

On a multiprocessor machine, you can request that a specific CPU execute a thread. Thread type determines the significance of such a request:

Thread type also determines the life of a context. You can optionally bind application threads (joinable, detached, daemon) to their context:

For information about the NKS functions you can use to create these types of threads, see Application Thread Functions and Anonymous Thread Functions.