From bd929e104fb3384cd4e0e5a747a2caf862467961 Mon Sep 17 00:00:00 2001 From: aygulozlem45-web Date: Fri, 5 Jun 2026 11:30:16 +0300 Subject: [PATCH] Add threaded decorator for concurrent execution Implement a threading decorator to run functions concurrently. --- Week07/threaded_aygul_ozkeklik.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Week07/threaded_aygul_ozkeklik.py diff --git a/Week07/threaded_aygul_ozkeklik.py b/Week07/threaded_aygul_ozkeklik.py new file mode 100644 index 00000000..4b71589f --- /dev/null +++ b/Week07/threaded_aygul_ozkeklik.py @@ -0,0 +1,14 @@ +import threading + +def threaded(n): + def decorator(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 thread in threads: + thread.join() + return wrapper + return decorator