Added utility function get_thread_id()