shtaxxx日記

コンピュータアーキテクチャについて研究している研究者の日記や技術紹介

2012-11-07から1日間の記事一覧

Threadingで実行した関数の実行結果を呼び出し元で知るには

Queue.put()とQueue.getを使う. import threading import thread from Queue import Queue def threaded_func(a, b, q): #return a + b ret = a + b q.put(ret) def main(): q = Queue() th = threading.Thread(target=threaded_func, args=(1, 2, q)) th.s…