From d90d9a37de3d91a69491c7959b5af77e92ad0a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bilal=20Ayakda=C5=9F?= <72439364+Bilal-AYAKDAS@users.noreply.github.com> Date: Sat, 4 Jan 2025 23:49:35 +0300 Subject: [PATCH] Create threaded_bilal_ayakdas.py --- Week07/threaded_bilal_ayakdas.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Week07/threaded_bilal_ayakdas.py diff --git a/Week07/threaded_bilal_ayakdas.py b/Week07/threaded_bilal_ayakdas.py new file mode 100644 index 00000000..60c503d3 --- /dev/null +++ b/Week07/threaded_bilal_ayakdas.py @@ -0,0 +1,16 @@ +import threading + +def threaded(n): + def decorator(func): + def wrapper(*args, **kwargs): + thread_list = [] + for _ in range(n): + thread = threading.Thread(target=func, args=args, kwargs=kwargs) + thread.start() + thread_list.append(thread) + + for _ in thread_list: + _.join() + return + return wrapper + return decorator