Thread library: get thread id