Detect if code is running on main thread or not

OS has .get_thread_caller_id() and .get_main_thread_id().