How an array of Threads works...
Greetings. I'm looking for some information regarding how Threads and arrays can work together. I've created a Thread class that extends Threads. I have an array of this class and as an event happens I trigger this thread to start. Once the Thread is finished, I attempt to remove its position in the array such:
Code:
classThreadExample example = new classThreadExample[5]
example[0].start(); //a
example[1].start(); //b
example[2].start(); //c
example[3].start(); //d
// Now say I want to remove Thread b
example[1]=example[2];
example[2]=example[3];
// Now I want to use example[3] space as a new event happens...
example[3] = new classThreadExample(passInSomeStuff);
example[3].start(); //Produces illegal Thread State
Please note that the code above is just a short remaking of what i'm trying to do and is not the exact code I have setup, but that is the general idea.
Now I know that once a Thread has been started, it cannot be started again, even when it has finished. What I am not sure of is why this thread finishes but does not disappear from the array. I've even tried setting the array spot to null and it will not produce any different results.
If you know of a proper way to deal with this kind of situation, any insight would be useful. Thanks.