FSM of the timer thread
RUNNING
TERMINATING
KILLING
TDEATH
Stop the thread (end its main loop)
New state = TERMINATING
TERM
TERM
KILL
TDEATH
TERM
KILL
TDEATH
pthread_join()
Send TDEATH to main fsm
New state = END
pthread_join()
Send TDEATH to main fsm
New state = END
pthread_cancel()
Send TDEATH to main fsm
New state = KILLING
pthread_join()
Send TDEATH to main fsm
New state = END
END