Home > Back-end >  In a multithreaded array, threads, looking for free or be destroyed to create...
In a multithreaded array, threads, looking for free or be destroyed to create...

Time:09-18

 var 
Threads: an array of TWebThread;
I: integer;

Setlength (Threads, listbox. Count + 1);

For I:=0 to listbox1. {count: 2 rows} do count - 1
The begin
Threads: [I]=TWebThread. Create (I, memo1);//to create three threads
end;


These no problem, I now shut down two of article, such as Threads [2] and Thread [0], Thread [1] are still in the running.

Problem is coming, and now I want to open a new thread, how to go from Threads inside the array to find one or more free thread number, recreate?

Threads [ . ] :=TWebThread. Create (I, memo1);

CodePudding user response:

Suggest you use the pointer chain, a node, a thread, thread through the loop check whether the wiring harness, and delete the node, so that hung on the pointer chain, is the end of a thread,

CodePudding user response:

ThreadList. Add (TWebThread. Create (I, memo1));