use threading without classes

Peter Hansen peter at
Wed Aug 31 14:18:43 CEST 2005

billiejoex wrote:
> Hi all. Hi would like to use two threads in a program but all the examples I 
> found on the net use oop programming that I doesn't love too much. :-)
> Can you code me a short example in wich two different functions are executed 
> at the same time, plz?

import time
from threading import Thread

def func1():
     print 'first func running'
     print 'first func done'

def func2():
     print 'second func running'
     print 'second func done'


Note that this is still using "OOP programming", and you can't 
effectively avoid this in Python without jumping through more hoops than 
you're really interested in, but this basically avoids the need to do 
OOP things like subclassing.


More information about the Python-list mailing list