Horje
run code at the same time python Code Example
run code at the same time python
from threading import Thread
import time

def parallelFunc():
    for i in range(100):
      print("1")
      time.sleep(0.2)
      
def parallelFunc2():
    for i in range(100):
      print("2")
      time.sleep(0.2)
      
th = Thread(target=parallelFunc)
th2 = Thread(target=parallelFunc2)

th.start()
th2.start()

#Run code in parallel with other 2 functions

th.join()
th2.join()

#2 functions will loop at the same time




Python

Related
closures in python Code Example closures in python Code Example
python f string 2 decimals Code Example python f string 2 decimals Code Example
change password django Code Example change password django Code Example
Find python background process id Code Example Find python background process id Code Example
jsonschema in python Code Example jsonschema in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8