unit CommonThread;
interface
uses
Classes;
type
TFun = procedure of object;
type
TFunThread = class(TThread)
fun: TFun;
private
{ Private declarations }
protected
procedure Execute; override;
public
constructor Create(AFun: TFun);
end;
implementation
constructor TFunThread.Create(AFun: TFun);
begin
inherited Create(False);
FreeOnTerminate := True;
Priority := tpLower;
fun := AFun;
end;
procedure TFunThread.Execute;
begin
fun;
end;
end.
用法:直接调用想要执行的过程就行了 TFunThread.Create(MyPro);,MyPro为想要执行的过程。