Nov-17-2017, 09:43 AM
Hi Team
I have a simple code in python which is below:
import threading
from random import *
class cal():
def __init__(self,a,b):
self.a=a
self.b=b
def add(self):
return self.a+self.b
for i in range(10000):
a = randint(1,10)
b = randint(1,10)
obj = cal(a,b)
print(a,'+',b,'=',obj.add())
Please advise how to achieve above using multi threading as if we run the above program in at least 10 parallel program, how to do that?
import threading from random import * class cal(): def __init__(self,a,b): self.a=a self.b=b def add(self): return self.a+self.b for i in range(10): a = randint(1,10) b = randint(1,10) obj = cal(a,b) print(a,'+',b,'=',obj.add())