2) You allocate 1 too few Should be:
Code: [Select]
setlength(MyArrayGoodThread, indexarray+1);
Repor
No : that is the right code :
if indexarray+1 > length(MyArrayGoodThread) then setlength(MyArrayGoodThread, indexarray+1);
Otherwise, you will have trouble with already created thread.
But, good, you are attentive..
1) Can you delete indexes from between? If you move indexes backwards (to fill the empty gap of deleted thread), you have to update the index value within each thread that are moved too.
Hum, i decide to not to play with moving index.
Too much problems, with few advantages...
If the thread was freed and assigned to nil, it is not very heavy inside the array...
And if the new length of array contain unassigned thread, it is not a big problem because nothing was created after setlength().
For that, i use a "twins" array of integer who vary in length with the thread array.
And when a thread is created => assign 1 to that twins{x].
So i can check in the thread array if thread{x] was already created.
PS : @ Taazz : part of you is inside uos now...