#!/usr/bin/env python import threading class the_test (threading.Thread): def __init__(self,level=0): threading.Thread.__init__(self) self.level = level def run(self): print(self.name) if self.level < 5: for i in xrange(3): the_test(self.level + 1).start() the_test().start()