C
Cloutar
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个多线程的演示程序
编译通过,能运行,只是一启动线程就报告异常∶存取错误
部分代码如下:
constructor TMyThread.Create(Col:TColor;XPos,YPos:integer);
begin
EColor:=Col;
X2:=XPos;
X1:=X2;
Y:=YPos;
inherited Create(true);
end;
procedure TMyThread.Execute;
begin
{ Place thread code here }
repeat
Step:=1;
X1:=X2;
X2:=X2+Step;
if X2<160 then
Step:=1
else
if X2>(Form1.ClientWidth-15)then
Step:=-1;
Synchronize(paint);//画一有色方块
Until Terminated;
end;
编译通过,能运行,只是一启动线程就报告异常∶存取错误
部分代码如下:
constructor TMyThread.Create(Col:TColor;XPos,YPos:integer);
begin
EColor:=Col;
X2:=XPos;
X1:=X2;
Y:=YPos;
inherited Create(true);
end;
procedure TMyThread.Execute;
begin
{ Place thread code here }
repeat
Step:=1;
X1:=X2;
X2:=X2+Step;
if X2<160 then
Step:=1
else
if X2>(Form1.ClientWidth-15)then
Step:=-1;
Synchronize(paint);//画一有色方块
Until Terminated;
end;