import time def delay(us): end_time = time.perf_counter_ns() + us * 1000 while time.perf_counter_ns() < end_time: print("", end="") if __name__ == '__main__': import threading def test(): time.sleep(1) print("hello") def test_2(): delay(1000 * 1000 * 10) threading.Thread(target=test).start() threading.Thread(target=test_2).start()