background: I\'m working on a logging library that is used by many programs.
I\'m assigning a human-readable name for each thread, the main thread should get \"main\", b
You can utilize some kind of shared name resource that allows threads that spawn to register a name (perhaps a map of thread id to name). Your logging system can then place a call into a method that gets the name via the thread ID in a thread-safe manner.
When the thread dies, have it remove it's name from the mapping to avoid leaking memory.
This method should allow all threads to be named, not just main.