Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Week07/threaded_ege_enc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import threading


def threader(n : int):
"""
This function is a decorator which takes an integer n as an argument
and returns a threaded function.

:param n:Number of threads
:return:Threaded function

"""
def decorator(func):
def wrapper():
threads = []
for _ in range(n): # 5 thread oluştur
t = threading.Thread(target=func)
t.start()
threads.append(t)
for t in threads:
t.join()
return wrapper
return decorator

@threader(4)
def func():
print("Hello World")

func()
Loading