update thread id api, add InvalidThreadId constant