pthread_setspecific

Assigns a value to the specified key for the calling thread.

Library:LibC
Classification:POSIX
Service:Threads

Syntax

  #include <pthread.h> 
   
  int   pthread_setspecific (
     pthread_key_t   key,
     const void     *value);
  

Parameters

key

(IN) Specifies the key for which the value is to be set.

value

(IN) Specifies the value to assign to the key.

Return Values

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

Decimal

Constant

Description

9

EINVAL

The specified key is not valid.

5

ENOMEM

The specified key is invalid (out of range).

Remarks

The value set by calling pthread_setspecific can be returned later by calling pthread_getspecific.

See Also