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