diff --git a/Week07/threaded_omer_gezici.py b/Week07/threaded_omer_gezici.py new file mode 100644 index 00000000..3fd420d1 --- /dev/null +++ b/Week07/threaded_omer_gezici.py @@ -0,0 +1,23 @@ +import threading +from functools import wraps +import random +import time + +def threaded(n: int): + def decorator(func): + @wraps(func) + def wrapper(*args, **kwargs): + threads = [] + + for i in range(n): + t = threading.Thread(target=func, args=args, kwargs=kwargs) + threads.append(t) + t.start() + + + for t in threads: + t.join() + + return None + return wrapper + return decorator