タグ

並列処理に関するcpthgliのブックマーク (1)

  • Pythonでマルチスレッド処理 - Qiita

    pythonを使ってマルチスレッド処理を行ないたい. pythonでスレッドを扱うにはthreadingモジュールを利用する. threadingモジュールでスレッドを扱うには二つの方法がある. threading.Threadのサブクラスを作る. threading.Threadのインスタンスを作る. それぞれについてサンプルを示す. サブクラスを作る サブクラスを作り,runにオーバーライドしてスレッド処理を実装する. 以下の例ではt秒おきにn回,時刻を表示するメソッドをrunとして実装した. import threading import time import datetime class TestThread(threading.Thread): """docstring for TestThread""" def __init__(self, n, t): super(Test

    Pythonでマルチスレッド処理 - Qiita
  • 1