def getinit(class_name):
“””动态加载模块”””
resultmodule = __import__(class_name, globals(), locals(), [class_name])
resultclass = getattr(resultmodule, class_name)
return resultclass()
import threading, time
class b:
def __init__(self, *args, **kwargs):
self.name = “b”
self.class_name = “a”
print “%s is inited” % (self.name)
def __del__(self):
print “%s is deleted” % (self.name)
def other_run(self, obj=none):
if obj:
obj.run()
def run(self, *args, **kwargs):
obj = getinit(self.class_name)
obj.run()
self.other_run(obj)
print “%s is run” % (self.name)
def treading():
n = 0
c = b()
while n