スレッド

2015/2/26

Python2.7.6, pyQt4.11

# -*- coding: utf-8 -*-

import time

from PyQt4 import QtCore

class AThread(QtCore.QThread):

    def run(self):
        count = 0
        while True:
            print(count)
            count += 1
            time.sleep(1)

def main():
    thread = AThread()
    thread.start()
    time.sleep(5)
    thread.exit()

if __name__ == "__main__":
    main()