I've added a fix similar to what you suggested except the non-MT case only applies to Windows. For non Windows platforms, we would require linking against the thread library to get the thread ID which is not the case at the moment. It is fixed in rev#96465.