import threading
def greet(name):
print(f"hello {name}")
t = threading.Thread(target=greet, args=("ada",))
t.start()
t.join()
print("done")What does this print?
- aIt raises TypeError because args must be a dict, not a tuple
- b"done" then "hello ada", since the main thread doesn't wait for t by default
- c"hello ada" then "done" — join() blocks until t finishes✓
- dIt prints nothing because target= expects a bound function call, not a reference
Explanation:
threading.Thread(target=greet, args=("ada",)) schedules greet("ada") to run in a new thread once start() is called. join() blocks the calling thread until t finishes, so "hello ada" is guaranteed to print before "done". args takes a tuple/iterable of positional arguments, not a dict.