The program I am creating requires an array of thread objects. More specifically I have a class which extends Thread. I am doing this so that each new object created runs on its own thread. If I want to kill the thread and remove it from the array element, so that I can create a new Thread object in that space, how do I do this? This is my thought.
I understand that removing reference to the thread will not actually stop the thread. To do this I would first need to interrupt the thread. To remove the thread object from the array, can I simply make it null? I.e.:
array[i].interrupt();
array[i] = null;
And then I would be able to create a new thread in that space?
array[i] = new Thread();
Assume that the run method of the Thread objects handles interruptions properly etc.