How to determine the current thread