Skip to main content
Version: Unreleased

getCurrentThreadId

Available from 0.13.0

getCurrentThreadId returns the id of the thread which currently executes JavaScript on the calling Runtime. The returned id is a stringified result of std::this_thread::get_id().

Reference​

Code

Code

Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.

function logThread() {
'worklet';
console.log(getCurrentThreadId());
}
logThread(); // The JS thread id.
scheduleOnUI(logThread); // The UI thread id.
runOnUISync(logThread); // The JS thread id.

Type definitions

function getCurrentThreadId(): string;

Returns​

getCurrentThreadId returns a string with the id of the current thread. The format of the id is platform-specific.

Call table​

ModeRN RuntimeUI RuntimeWorker Runtime
Bundle Mode✅✅✅
Legacy Eval Mode✅✅✅

What does it mean?

Platform compatibility​

NativeWeb
✅❌