May-16-2019, 10:26 AM
Hello,
Just started learning multi threading concept in python as beginner..I want to print values
1 to 10 with two different functions using multithreading concept within a class ,my code is below:
Just started learning multi threading concept in python as beginner..I want to print values
1 to 10 with two different functions using multithreading concept within a class ,my code is below:
import threading class Class1: i=1 j=1 def f1(): global i while i<=10: print(" I is now %d" %i) i=i+1 def f2(): global j while j<=10: print("J is now %d" %j) j=j+1 def Main1(): t1=threading.Thread(target=f1()) t2=threading.Thread(target=f2()) t1.start() t2.start() ob=Class1() ob.Main1()But getting error:
Error:Traceback (most recent call last):
File "C:/Threading1.py", line 26, in <module>
ob.Main1()
TypeError: Main1() takes 0 positional arguments but 1 was given