弄个多线程老是报地址错误的错。。汗Σ( ° △ °|||)︴。。
弄了半天才发现create的时候错了。。居然直接用hthread.create(False)。。。尼玛hthread这个都没赋值的。。
下面贴代码,如何用Tthread创建多线程。
unit gateServer; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ScktComp,IDHttp,StrUtils,HttpApp; type AutoGateThread = class(TThread) protected procedure Execute(); override; end;
type
TFrmMain = class(TForm)
procedure Button1Click(Sender: TObject);
end;
var FrmMain: TFrmMain; hthread : AutoGateThread; implementation uses superobject; {$R *.dfm} procedure TFrmMain.Button1Click(Sender: TObject); begin hthread := AutoGateThread.create(False); end; procedure AutoGateThread.Execute(); var i:Integer; begin inherited; for i:=0 to 1000 do begin sleep(5000); ShowMessage('continue'); end; end; end.
是不是很简单。