Skip to content

Commit d90d9a3

Browse files
Create threaded_bilal_ayakdas.py
1 parent 133e6cb commit d90d9a3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Week07/threaded_bilal_ayakdas.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import threading
2+
3+
def threaded(n):
4+
def decorator(func):
5+
def wrapper(*args, **kwargs):
6+
thread_list = []
7+
for _ in range(n):
8+
thread = threading.Thread(target=func, args=args, kwargs=kwargs)
9+
thread.start()
10+
thread_list.append(thread)
11+
12+
for _ in thread_list:
13+
_.join()
14+
return
15+
return wrapper
16+
return decorator

0 commit comments

Comments
 (0)