am I right that I can also change that pthread to a detached pthread?
Yes, that's correct.
If that's the case, how can I check if a pthread is joinable?
You can't, and asking to do so doesn't make any sense. Unless you have a joinable pthread that you know for a fact has not yet been joined, there is no pthread for you to check. A detached, or joined, pthread may no longer exist, so there is no "a pthread" for you to check on.
There is no way to check whether a thing that might or might not actually be a thread is a thread. People who suggest otherwise are asking you to rely on behavior that is not guaranteed, and that would be extremely foolish.
And how can I change a pthread from joinable to detached?
You can detach it, or it can detach itself, at any time by calling pthread_detach
. The most common pattern is that something owns the thread, and that thing is responsible for joining the thread when it's finished (or shutting down). If you just want a thread to run until it's done without any kind of supervision or ownership, detach it or have it detach itself.