var t1:thread3;
begin
thread3.Create(false);
t1.Resume;
end;
-----------------
t1 := thread3.Create(false);
no need to call resume,the thread will be run after create(false);

解决方案 »

  1.   

    t1:=thread3.create(false);
    t1.resume;
    //这两句可以用t1:=thread3.create(true);
    另外你的Execute()在哪?
      

  2.   

    前面写错了
    应该只需要t1:=thread3.create(false);
      

  3.   

    chenjbjbjb:
         t1:=thread3.create(false);
    同样不行,错误提示为:AbstractError
      

  4.   

    谢谢 chenjbjbjb(哈哈) 
    注意是在5.0下,有补丁包吗?补丁包1已经打了!
      

  5.   

    在线程中有没有的Execute()在哪? 
      

  6.   

    thread3=class(tthread)
        ttt:integer;
        procedure execute;override; //这里有问题
        private
        { Private declarations }
        protected
          procedure js;//一个用于计算子程序
      public
        { Public declarations }  end;应该是
    thread3=class(tthread)
        ttt:integer;
        private
        { Private declarations }
        protected
          procedure execute;override; //应该解决了
          procedure js;//一个用于计算子程序
      public
        { Public declarations }  end;
      

  7.   

    thread3=class(tthread)
        ttt:integer;
        private
        { Private declarations }
        protected
          procedure execute;override; //应该解决了-----仍然不行(5.0)
          procedure js;//一个用于计算子程序
      public
        { Public declarations }  end;
      

  8.   

    Execute有没有具体的实现,将Thread3的代码全部贴出来!
      

  9.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      thread3=class(tthread)
      private
        ttt:integer;
        { Private declarations }
      protected
        Procedure execute;override;
          //rocedure js;//一个用于计算子程序
      public
        { Public declarations }  end;
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    Var
      t1:thread3;
    begin
      t1 := thread3.Create(false);
    end;{ thread3 }procedure thread3.execute;
    begin
      inherited;
    //
    end;end.
    --------------------------
    no error here
    we need more code.
      

  10.   


    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        procedure FormCreate(Sender: TObject);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
     TMyThread=class(tthread)    private
        { Private declarations }
        protected
           procedure execute;override;//这是继承基类的Execute
          procedure js;//一个用于计算子程序
      public
        { Public declarations}
    end;
     var
    Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    beginend;{ TMyThread }procedure TMyThread.execute;
    begin
      inherited;
    js;
    end;procedure TMyThread.js;
    var i:integer;
    begin
    for i:=1 to 4000 do
    begin
      form1.Edit1.Text:=inttostr(i);
    end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var t1:Tmythread;
    begin
     t1:=Tmythread.Create(false);
    end;end.
      

  11.   

     procedure TForm1.Button1Click(Sender: TObject);
    var t1:thread3;
    begin
    thread3.Create(false);
    t1.Resume;
    end;把t1定义成一个局部变量,那么后面t1这个线程怎么关闭呢?
    还有t1:=thread3.Create(false);
    If CreateSuspended is False, Execute is called immediately.
    下面的那个resume是多余的!
    还有你的procedure js在什么时候执行啊?
    放在execute时间里面吗?
      

  12.   

    procedure TMyThread.execute;
    begin
      inherited;
      Synchronize(js);//由于js要处理主线程的Edit1所以要同步
    end;
      

  13.   

    t1只是一个指针,在函数结束时被释放,但它指向的内存没有被free,
    c的习惯一般new完了一定要delete,在tthread里,要么waitfor,要么FreeOnTerminate=true
      

  14.   

    procedure TMyThread.execute;
    begin
      FreeOnTerminate=true;
      Synchronize(js);//由于js要处理主线程的Edit1所以要同步
    end;
      

  15.   

    我现在已经解决了,但不知为什么?
    procedure TMyThread.execute;
    begin
     // inherited; 此句去掉,为什么??
      js;
    end;
      

  16.   

    execute是在TThread中的虚函数不能被继承