您好我对关键部分有疑问.我有两个线程scannerThread和scannerchild thread.Code for Scannerthread如下所述.
procedure ScannerThread.Execute;
var
I: Integer;
ScannerCh: Array of ScannerChild;
IpList: TStringlist;
IPCount: Integer;
begin
IpList:=TStringList.Create;
IF GetNumberOfIpsInRange(Ip_From, Ip_To, IpList) then // Function call that returns iplist if TRUE
begin
Try
if Assigned(LvHosts) then // Clear
LvHosts.Clear;
IPCount := IpList.Count;
SetLength(ScannerCh, IPCount);
I := 0;
repeat
while GetTThreadsCount(GetCurrentProcessId) > tcount do // Tcount is threads to create which is given by user
Sleep(10);
ScannerCh[I]:=ScannerChild.Create(True, IpList[i]);
ScannerCh[I].FreeOnTerminate := True;
ScannerCh[I].LvHostname := LvHosts;
ScannerCh[I].Resume;
Inc(I);
until I = IPCount; …Run Code Online (Sandbox Code Playgroud) delphi multithreading synchronization delphi-7 critical-section