VYAS ASHISH M-NTB837 schrieb: > I have an object which has a run() method. But I can call it only once. > Calling the start() again will give > > RuntimeError: thread already started > > So what is the way to do this? > > I thought of doing a deep copy of the object, as shallow copy will also > lead to the above error. > I tried this: > - deepcopy the object > - call start() for the object you got from deepcopy > - delete the object. > > Is there a simpler way to achieve this?
Indeed, there is: def threaded(): """ do threaded stuff here """ Thread(target=threaded).start() Thread(target=threaded).start() Thread(target=threaded).start() Thread(target=threaded).start() Thread(target=threaded).start() Now threaded() runs five times. Python is not Java where one has to subclass from Thread (AFAIR the dark ages where I used to speak Javanese). Mick, -- http://mail.python.org/mailman/listinfo/python-list