@@ -0,0 +1,946 @@
+#!/usr/bin/env python2%0A%0A# -*- coding: utf-8 -*-%0A# http://www.cnblogs.com/semiok/articles/2640929.html%0A# create threading.Thread sub-class%0A%0Aimport threading%0Aimport time%0A%0A#The timer class is derived from the class threading.Thread%0Aclass timer(threading.Thread):%0A    def __init__(self, num, interval):%0A        threading.Thread.__init__(self)%0A        self.thread_num = num%0A        self.interval = interval%0A        self.thread_stop = False%0A%0A    # Overwrite run() method, put what you want the thread do here%0A    def run(self):%0A        while not self.thread_stop:%0A            print('Thread Object(%25d), Time: %25s%5Cn' %25 (self.thread_num, time.ctime()))%0A            time.sleep(self.interval)%0A%0A    def stop(self):%0A        self.thread_stop = True%0A%0Adef test():%0A    thread1 = timer(1, 1)%0A    thread2 = timer(2, 2)%0A    thread1.start()%0A    thread2.start()%0A    time.sleep(10)%0A    thread1.stop()%0A    thread2.stop()%0A    return%0A%0Aif __name__ == '__main__':%0A    test()%0A

add test_thread_class