---
name: "pthread_threadid_np"
section: "3"
platform: "macos"
package: "libpthread"
version: "539.100.4"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/pthread_threadid_np"
---

# pthread\_threadid\_np(3)

get the calling thread's unique ID

## NAME

**pthread\_threadid\_np** – get the calling thread's unique ID

## SYNOPSIS

**#include \<pthread.h\>**

*int*\

**pthread\_threadid\_np**(*pthread\_t thread*, *uint64\_t \*thread\_id*);

## DESCRIPTION

The **pthread\_threadid\_np**() function stores the system-wide unique integral ID of *thread* in the location spedified by *thread\_id*. If *thread* is NULL, the ID of the current thread is provided.

## RETURN VALUES

If successful, the **pthread\_threadid\_np**() function will return zero.  Otherwise an error number will be returned to indicate the error.

## ERRORS

The **pthread\_threadid\_np**() function will fail if:

- \[EINVAL\]

  NULL value for *thread\_id*.

- \[ESRCH\]

  Non-existent thread *thread*.

## SEE ALSO

[pthread\_self(3)](/pthread_self/3.md)
