import threading, time
a = 50
b = 50
c = 50
d = 50
def printvars():
print "a =", a
print "b =", b
print "c =", c
print "d =", d
def threadcode():
global a, b, c, d
a += 10
b = b + 10
c = 100
d = "Hello"
print "[ChildThread] Values of variables in child thread:"
printvars()
print "[MainThread] Values of variables before child thread:"
printvars()
t = threading.Thread(target = threadcode, name = "ChildThread")
t.setDaemon(1)
t.start()
t.join()
print "[MainThread] Values of variables after child thread:"
printvars()
17.2.Daemon |
| 17.2.1. | Threading with variables |