Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the name of a Win32 Thread?

I know of the non-intuitive process to set the name of a thread under Windows (see "How to set name to a Win32 Thread?"). Is there a way to get the name of the thread? I don't see any Windows API that lets me do this (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx).

like image 658
Michael Kelley Avatar asked Feb 20 '12 18:02

Michael Kelley


People also ask

How do I get the thread name in C++?

The pthread_getname_np() function retrieves the name of the thread. The buffer specified by name must be at least 16 characters in length. The returned thread name will be null terminated in the output buffer. By default, each thread is unnamed.

How do you find the thread ID of a thread handle?

If you have a thread identifier, you can get the thread handle by calling the OpenThread function. OpenThread enables you to specify the handle's access rights and whether it can be inherited. A thread can use the GetCurrentThread function to retrieve a pseudo handle to its own thread object.

Is Win32 thread a library?

The Win32 thread library is a kernel-level library available on Windows systems. The Java thread API allows thread creation and management directly in Java programs.

What are Win32 threads?

The Win32 threads are implemented in the kernel space of Windows OS. The multi-threaded applications can use the Win32 API library similar to Pthread library. We must include Windows. h header file while using win32 API.


1 Answers

Threads don't actually have names in Win32. The process via RaiseException is just a "Secret Handshake" with the VS Debugger, who actually stores the TID => Name mapping. Windows itself has no notion of a thread "Name".

like image 58
Ana Betts Avatar answered Oct 06 '22 05:10

Ana Betts