![]() |
|
#1
|
|||
|
|||
![]() Прошу помочь с разобраться с потоками. Написал для себя парсер ip диапазонов который разбивает диапазон ip на отдельные и здесь проблема, встречаются такие громадины как "200.128.0.0 201.95.255.255" это огромное количество ip. Хотелось бы что бы кто то помог сделать расчет хотя бы потоков в 10, а то расчет такой сети будет длиться примерно 4 часа, а то и больше. Надеюсь на скорую помощь.
Смотрел исходники многопоточных программ но с них научишься чему угодно но только не потокам. В книжке к сожалению написано только про один поток помимо главного(Библия Delphi 3-е изд.). Код парсера: Код:
procedure TForm1.Button1Click(Sender: TObject); var f: TStringList; i, j: integer; diapazon, sp: string; first, sfirst: integer; second, ssecond: integer; third, sthird: integer; fourth, sfourth: integer; begin f:=TStringList.Create(); f.LoadFromFile('ipd.txt'); for I := 0 to f.Count - 1 do begin diapazon := f.Strings[i]; sp := copy(diapazon, pos(' ', diapazon)+1, Length(diapazon)); first := strtoint(copy(diapazon, 0, pos('.', diapazon)-1)); sfirst := strtoint(copy(sp, 0, pos('.', sp)-1)); Delete(diapazon, 1, pos('.', diapazon)); Delete(sp, 1, pos('.', sp)); second := strtoint(copy(diapazon, 0, pos('.', diapazon)-1)); ssecond := strtoint(copy(sp, 0, pos('.', sp)-1)); Delete(diapazon, 1, pos('.', diapazon)); Delete(sp, 1, pos('.', sp)); third := strtoint(copy(diapazon, 0, pos('.', diapazon)-1)); sthird := strtoint(copy(sp, 0, pos('.', sp)-1)); Delete(diapazon, 1, pos('.', diapazon)); Delete(sp, 1, pos('.', sp)); fourth := strtoint(copy(diapazon, 0, pos(' ', diapazon)-1)); sfourth := strtoint(copy(sp, 0, Length(sp))); Delete(diapazon, 1, pos('.', diapazon)); Delete(sp, 1, pos('.', sp)); while j<>4 do begin Application.ProcessMessages; if first<>sfirst then first:=first+1; if second = ssecond then if third = sthird then if fourth = sfourth then begin second:=second+1; fourth:=0; third:=0; second:=0; end; if second<>ssecond then; if third = sthird then if fourth = sfourth then begin second:=second+1; fourth:=0; third:=0; end; if third<>sthird then if fourth = sfourth then begin third:=third+1; fourth:=0; end; if fourth<>sfourth then fourth:=fourth+1; Memo1.Lines.Add(inttostr(first)+'.'+inttostr(second)+'.'+inttostr(third)+'.'+inttostr(fourth)); if (first = sfirst) and (second = ssecond) and (third = sthird) and (fourth = sfourth) then j:=4; end; j:=0; end; f.Free; end; Буду очень благодарен за помощь. |