File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change 11import threading
22
33def 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+
You can’t perform that action at this time.
0 commit comments