Skip to content

Commit d6c3264

Browse files
authored
Update threaded_rukiye_ilhan.py
1 parent d0f5447 commit d6c3264

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Week07/threaded_rukiye_ilhan.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import threading
22

33
def threaded(n):
4-
"""İlk fonksiyon - thread sayısını parametre olarak alır"""
5-
def wrapper(func):
6-
"""İkinci fonksiyon - thread'leri oluşturur ve yönetir"""
7-
threads = []
8-
#istenen n sayıdaki tjread oluşturldu
9-
for _ in range(n):
10-
t = threading.Thread(target=func)
11-
threads.append(t)
12-
t.start()
13-
# Bütün thread'lerin bitmesini bekle
14-
for thread in threads:
15-
thread.join()
16-
return func # Orijinal fonksiyonu döndür
17-
return wrapper
4+
def decorator(func):
5+
def wrapper(*args, **kwargs):
6+
threads = []
7+
for i in range(n):
8+
t = threading.Thread(target=func, args=args, kwargs=kwargs)
9+
threads.append(t)
10+
t.start()
11+
for thread in threads:
12+
thread.join()
13+
return wrapper
14+
return decorator
15+

0 commit comments

Comments
 (0)