Make 2 functions run at the same time

John picture John · Jun 2, 2010 · Viewed 127.3k times · Source

I am trying to make 2 functions run at the same time.

def func1():
    print 'Working'

def func2():
    print 'Working'

func1()
func2()

Does anyone know how to do this?

Answer

chrisg picture chrisg · Jun 2, 2010

Do this:

from threading import Thread

def func1():
    print('Working')

def func2():
    print("Working")

if __name__ == '__main__':
    Thread(target = func1).start()
    Thread(target = func2).start()