Best Answer: How Do I Find the Current Thread Id in Linux?
Contents How Do I Find the Thread Id in Linux? Identifying the Thread on Unix® and Linux® Systems, You Can Use the Top Command: $ Top -N 1 -H -P [Pid]Replacing...
Contents
How do I find the thread ID in Linux?
Identifying the thread
- On Unix® and Linux® systems, you can use the top command: $ top -n 1 -H -p [pid]replacing [pid] with the process ID of the affected process.
- On Solaris®, you can use the prstat command: $ prstat -L -p [pid]replacing [pid] with the process ID of the affected process.
How do I find thread ID?
The pthread_self() function is used to get the ID of the current thread. This function can uniquely identify the existing threads. But if there are multiple threads, and one thread is completed, then that id can be reused. So for all running threads, the ids are unique.