mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-31 03:40:38 +01:00
51 lines
643 B
ObjectPascal
51 lines
643 B
ObjectPascal
program testthreads;
|
|
|
|
{$mode objfpc}
|
|
|
|
uses
|
|
sysutils,
|
|
classes;
|
|
|
|
type
|
|
TMyThread=class(TThread)
|
|
private
|
|
ch : char;
|
|
protected
|
|
procedure Execute; override;
|
|
public
|
|
constructor Create(c:char);
|
|
end;
|
|
|
|
procedure TMyThread.Execute;
|
|
begin
|
|
repeat
|
|
write(ch);
|
|
until false;
|
|
end;
|
|
|
|
|
|
constructor TMyThread.Create(c:char);
|
|
begin
|
|
ch:=c;
|
|
inherited Create(false);
|
|
end;
|
|
|
|
var
|
|
t1,t2 : TMyThread;
|
|
begin
|
|
t1:=TMyThread.Create('a');
|
|
t2:=TMyThread.Create('b');
|
|
readln;
|
|
t2.Terminate;
|
|
readln;
|
|
t1.Terminate;
|
|
readln;
|
|
t2.Destroy;
|
|
t1.Destroy;
|
|
end.
|
|
$Log$
|
|
Revision 1.2 2000-07-13 11:33:05 michael
|
|
+ removed logs
|
|
|
|
}
|