谁说不能?????好好看看unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
  tmythread=class(tthread)
  public
    procedure execute;override;
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
  t:tmythread;
begin
  t:=tmythread.Create(true);  t.FreeOnTerminate:=true;
  t.execute;
end;{ tmythread }procedure tmythread.execute;
begin
  inherited;
  form1.Label1.Caption:=datetimetostr(now);
  sleep(10000);
  form1.Label2.Caption:=datetimetostr(now);end;end.

解决方案 »

  1.   

    to :qiubolecn(来自差生市)
    我在线程中写sleep,在编译时告诉我‘sleep’是没有定义的语句/变量,搞不清楚是怎么回事?
    没有人碰到过类似的问题吗?
     
      

  2.   

    我还以为真不能用呢!
    在Sleep上边按F1,把帮助里的Unit的名字加进你程序的USES部分,再看看能不能!
      

  3.   

    我找到解决的办法了:
    1。在主程序中public部分声明一过程sleeptime;
    2。在实现部分写过程为sleep(20000);
    3。在线程中引用它。谢谢大家的支持!!
      

  4.   

    to :cul(恐龙++)
    在线程uses语句中加入windows。
    谢谢你的支持!