Use thread methods rather than time.sleep to wait