我现在有一个strings
里面存有n个string.
现在我该如何根据strings里面的string数量(也就是n)
来创建相同数量(n个)线程
然后每个线程按顺序从strings里面读出一个string(不重复).
以便于以后的的独立操作。
请帮帮忙
分不够可以再加~~一定要解决问题~~谢谢大家,最好有代码参考~~

解决方案 »

  1.   

    unit Unit2;interfaceuses
      Classes;type
      TestThread = class(TThread)
      private
        FString: string;
      protected
        procedure Execute; override;
      public
        constructor Create(AString: string);
      end;implementation{ Important: Methods and properties of objects in visual components can only be
      used in a method called using Synchronize, for example,      Synchronize(UpdateCaption);  and UpdateCaption could look like,    procedure TestThread.UpdateCaption;
        begin
          Form1.Caption := 'Updated in a thread';
        end; }{ TestThread }constructor TestThread.Create(AString: string);
    begin
      FString = AString;
      inherited Create(False);
    end;procedure TestThread.Execute;
    begin
      //FreeOnTerminate := True;
      //这里写上你的操作string代码
    end;end.
    创建线程
    for I := 0 to strings.count - 1 do
      with TTestThread.Create(strings[I]) do ...;