モナーの *やさしい* Delphi質問スレ Ver.5
■ このスレッドは過去ログ倉庫に格納されています
0586デフォルトの名無しさん
NGNGCreate と同時にスレッドが始まりますよね。それはよいのですが、
パラメータを True にしておき、相次いで2つのスレッドを Execute すると、
最初のスレッドが終了してから出ないと次のスレッドが開始しません。
なぜなのでしょうか。
type
TMyThread = class(TThread)
public
Interval:Longint;
ProgressBar:TProgressBar;
constructor Create(AInterval:Integer; PBar:TProgressBar);
procedure Execute; override;
end;
constructor TMyThread.Create(AInterval: Integer; PBar: TProgressBar);
begin
inherited Create(True);
Interval := AInterval;
ProgressBar:=PBar;
end;
procedure TMyThread.Execute;
var
I,S:Integer;
begin
inherited;
for I:=0 to 100 do begin
S := GetTickCount;
while GetTickCount <= S + Interval do;
ProgressBar.Position := I;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Th1, Th2: TMyThread;
begin
Th1 := TMyThread.Create( 30, Self.ProgressBar1 );
Th2 := TMyThread.Create( 20, Self.ProgressBar2 );
Th1.Execute;
Th2.Execute;
end;
■ このスレッドは過去ログ倉庫に格納されています