I guess uglyness is in the eye of the beholder but I prefer to avoid global data where at all possible.However you are wrong to say that my threads are created at start-up and, in addition, the objects which access the hardware need to be deleted and created dynamically in my application so some form of INVALID_THREAD_ID token is required by my software.
if (tsk == 0) { // Invalid task ID sysThreadError(osErrorNoMemory); // Create task failed (Out of memory) return NULL; }