2013-01-22 22 views
0

我是線程新手(雖然不是Python的初學者),但我無法使線程正常工作。我有以下的簡單(est)程序,但我似乎無法獲得函數do_something()調用。我必須做一些非常基本的錯誤。誰能告訴我什麼?萬分感謝!無法讓簡單的Python線程工作

import threading 

def do_something(): 
    print 'Function called...' 

t = threading.Thread(target=do_something) 

當然,我已經不知不覺以前刪除的t.start()指令(你這該死的突觸觸摸板!!!!!!)

回答

5

你應該開始線程:

import threading 

def do_something(): 
    print 'Function called...' 

t = threading.Thread(target=do_something) 
t.start() # you forgot this line 
1

你需要啓動你的線程:

t.start()