On linux, we have pthread_kill() to do this. I’m trying to find a Windows counterpart for it.
In other words, given a thread id, is there a way to decide whether the thread is still running or not?
GetExitCodeThread() is the closest I’ve found, however, it needs thread handle rather than thread id as its parameter.
You should not use a thread id for this purpose: thread ids can be reused, so if you get a thread id, then that thread exits, another thread can be started with that same thread id.
The handle does not have this problem: once a thread terminates, all handles to that thread will reflect the terminated state of the thread.
You can obtain a handle for a thread with a given id using
OpenThread; you can then pass that handle toGetExitCodeThreadto determine whether the thread has exited.