0

Multithreading in python

Please check the code and help to remove bug and run this. from threading import * class hello(): def run(self): for i in range(200): print("Hello") class hii(): def run(self): for i in range(200): print("Hii") h1=hello() h2=hii() h1.start() h2.start()

30th Apr 2020, 6:13 PM
Hasnain Jeelani
Hasnain Jeelani - avatar
4 Réponses
+ 3
a=Thread(target=h1.run) b=Thread(target=h2.run) a.start() b.start()
30th Apr 2020, 6:47 PM
Abhay
Abhay - avatar
+ 2
You need to make your custom classes inherit from the Thread class like this : class hello(Thread): Then the code will run.
30th Apr 2020, 6:38 PM
Tibor Santa
Tibor Santa - avatar
+ 2
you are not using threading, you just imported it. and your classes have run() methods not start()
30th Apr 2020, 6:38 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
I have tried that too putting thread in class but the error is “”not able to call list like this
30th Apr 2020, 7:07 PM
Hasnain Jeelani
Hasnain Jeelani - avatar