So, I'm trying to run 2 threads simultaneously. My code looks like this:
from threading import Thread
def Main():
n = 10
k = 2
max = n//k
def firstfunc():
for i in range(0, max):
print(i)
def secondfunc():
for i in range(0, max):
print(i+10)
if __name__ == '__main__':
T1 = Thread(target=Main().firstfunc, args=()).start
T2 = Thread(target=Main().secondfunc, args=()).start
for thread in [T1, T2]:
thread.join()
The error that throws:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [2], line 14
11 print(i+10)
13 if __name__ == '__main__':
---> 14 T1 = Thread(target=Main().firstfunc, args=()).start
15 T2 = Thread(target=Main().secondfunc, args=()).start
16 for thread in [T1, T2]:
AttributeError: 'NoneType' object has no attribute 'firstfunc'
I searched online and I consulted also stackoverflow's answers to similar questions, but nothing worked for me. Does anyone know what I'm doing wrong?