DELPHI怎么实现多线程? 奇怪的问题

来源:百度知道 编辑:UC知道 时间:2024/06/21 00:34:12
最近在学DELPHI,程序没有多线程很麻烦,自己找资料看半天也没看懂,希望高手写个例程给我看看。最好是用一个线程累加数并显示在界面上,按停止按钮就可以结束线程。谢谢

unit bncthrd;
  interface
  uses
  winprocs,classes,graphics,extctrls;
  type
  tbouncethread=class(tthread)
  private
  fshape:tshape;
  fxspeed:integer;
  fyspeed:integer;
  procedure moveshape;
  protected
  procedure execute;override;
  public
  constructor create(suspended:boolean;shape:tshape;xspeed,yspeed:integer);
  propertyshape:tshapereadfshape;
  end;
  implementation
  procedure tbouad.moveshape;
  var
  maxheight,maxwidth:integer;
  begin
  with fshape do
  begin
  left:=left+fxspeed;
  top:=top+fyspeed;
  if(left=0) or(left+width=parent.width)then
  fxspeed:=fxspeed*-1;
  if(top=0)or(top=height+parent.height)then
  fyspeed:=fyspeed*-1;
  end;
  end;
  procedure tbouncethread.execute;
  begin
  while not terminated do
  begin
  synchronize(moveshape);
  end;