NXThreadDetach

Converts a joinable thread to a detached (non-joinable) thread.

Library:LibC
Classification:NKS
Service:Threads

Syntax

  #include <nks/thread.h>
   
  int NXThreadDetach (
     NXThreadId_t   tid);
  

Parameters

tid

(IN) Specifies the ID of the thread to convert to a detached thread.

Return Values

If successful, returns 0; otherwise, returns a nonzero error code:

Decimal

Hex

Constant

Description

9

0x09

NX_EINVAL

The target thread is not a joinable thread.

77

0x4D

NX_ESRCH

The specified thread ID is invalid; it might not exist.

Remarks

If successful, NXThreadDetach converts the joinable thread specified by the tid parameter to a detached thread. Such a thread can no longer be joined using the NXThreadJoin function.

If a thread has already called NXThreadJoin for the thread being detached, the thread returns from NXThreadJoin with an error indicating that the thread being joined was not joinable.If the thread being detached has already exited and is waiting for a join operation, it will be cleaned up immediately. The thread cannot be subsequently joined using NXThreadJoin.

The use of NXThreadDetach is strongly discouraged and is provided only to support porting code written to other threads libraries, notably pthreads.

NXThreadDetach can be called by a thread for itself, but tid has to be obtained by calling NXThreadGetId.