delphi怎样做成多线成

解决方案 »

  1.   

    File->New->Other中可以选择TThread Objects
    即创建了一个包含线呈的单元(设为unit2如下)
    unit Unit2;
    interface
    uses
      Classes;type
      MyThread = class(TThread)
      private
        { Private declarations }
      protected
        procedure Execute; override;
      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 MyThread.UpdateCaption;
        begin
          Form1.Caption := 'Updated in a thread';
        end; }{ MyThread }procedure MyThread.Execute;
    begin
      //在这里编写代码即可
    end;end.
      

  2.   

    在主程序中调用
    MyThread.create(false);//创建线呈并使其立即执行