Threading program with issues when executing from IDLE
Batista, Facundo
FBatista at uniFON.com.ar
Mon Mar 29 14:00:55 EST 2004
People, executing the following code from command line, it works as expected
(you see "th1 - 2" *always* after "th2 - 2").
But when I execute from IDLE one of two things happens:
- Everything freezes up after "th1 - 1".
- The program finishes but after I get an strange internal IDLE error.
There's a way to avoid that?
The code:
-----------------
import threading
def thfunc1():
print "th1 - 1"
event.wait()
print "th1 - 2"
def thfunc2():
print "th2 - 1"
print "th2 - 2"
event.set()
event = threading.Event()
th1 = threading.Thread(target=thfunc1)
th2 = threading.Thread(target=thfunc2)
th2.start()
th1.start()
-----------------
Thank you all!
. Facundo
More information about the Python-list
mailing list