import threading import time class timer(threading.Thread): def __init__(self,no,interval): threading.Thread.__init__(self) self.no=no self.interval=interval def run(self): while True: print 'Thread Object (%d), Time:%s'%(self.no,time.ctime()) time.sleep(self.interval) def test(): threadone=timer(1,1) threadtwo=timer(2,3) threadone.start() threadtwo.start() print 'main thread' if __name__=='__main__': test()