Purpose is clear, just start the thread *ONLY* if not already running, return true if success or false if thread was already running.
Where's the caveat ? It's simply in the time BETWEEN the start of ThreadCb() callback and the setting of 'inThread' variable to true. If code calls fast enough the StartThread() routine, it can happen that the Thread callback is in the middle of startup code BUT has still NOT SET the 'inThread' flag; so the StartThread() routine believes thread isn't running and calls it again.
The solution :
So, I've moved the 'inThread' flag SETTING from the thread routine to its caller; the reset still belong to thread routine.
Now it's the caller that has the responsibility of setting the variable, so it can't happen that thread routine performs some stuffs between check and launch.