May 04, 2005
I have a simple multithreaded server that creates Threads as it receives connections from the network.  Once a connection is terminated, the Thread returns 0 from int run(), as it should.  After some large number of connections, I receive the error ThreadError: Thread error: failed to start when trying to create a new connection-handling Thread.  Does the GC not collect Thread objects?

I've attempted to rectify the situation by creating a pool of reuasble Thread objects and trying to restart them.  No dice.  It seems that once you start() a Thread, there's no going back.  Even if the thread's int run() returns 0, it's not possible to restart it.  Do I have to explicity delete the old Thread objects?  I could try that, since I haven't yet.  It just seems silly that a Thread cannot be reusable.

BTW, I should mention that I'm working on Linux.

Regards,
James Dunne