Re: use threading without classes
- From: Peter Hansen <peter@xxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 08:18:43 -0400
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'
time.sleep(1)
print 'first func done'def func2():
print 'second func running'
time.sleep(1)
print 'second func done'Thread(target=func1).start() Thread(target=func2).start()
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.
-Peter .
- Follow-Ups:
- Re: use threading without classes
- From: billiejoex
- Re: use threading without classes
- References:
- use threading without classes
- From: billiejoex
- use threading without classes
- Prev by Date: Re: .pth files in working directory
- Next by Date: module not found in IIS virtual dir
- Previous by thread: Re: use threading without classes
- Next by thread: Re: use threading without classes
- Index(es):