I am new to threading (though not a beginner in Python) and I am having trouble making a thread work. I have the following simpl(est) program, but I cannot seem to get the function do_something() called. I must be doing something very basic wrong. Can anyone tell me what? Thanks a ton!
import threading
def do_something():
print 'Function called...'
t = threading.Thread(target=do_something)
Of course, I had unwittingly previously deleted the t.start() instruction (Damn you Synaptic touchpad!!!!!!)
You should start the thread:
import threading
def do_something():
print 'Function called...'
t = threading.Thread(target=do_something)
t.start() # you forgot this line
您需要启动线程:
t.start()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.