Python Tutorial

Thursday, October 28, 2010

Python Threading

'''
    This code use python threading syntax
    - Save this class named 'ThreadClass.py'
'''
import threading
import time

class ThreadClass(threading.Thread):
    def __init__(self,data):
        threading.Thread.__init__(self)
        self.data=data
        
    def run(self):
        for i in range(0,3):
            print "output: ",self.data
            time.sleep(1);

0 comments:

Post a Comment