Rules for Writing Threads
A thread is not called but created; if it returns, either explicitly with a return statement or implicitly by reaching the end of the function, the thread is deleted just as if DeleteRtThread was called. When the main thread of a process returns, the whole process is terminated.
Reentrancy means that the same code can be executed by different threads; this requires that all variables specific for a thread are either allocated on the stack or dynamically. Global (or static) data can be used to share information between threads; in such a case typically, some synchronization is needed to avoid race conditions.