blob: 0deef4b064aa6d37fd70f1d0bcb95b324a37d6c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
{$mode objfpc}
uses
{$ifdef unix}
cthreads,
{$endif}
sysutils,
classes;
type
tmythread = class(tthread)
fs: ansistring;
constructor create(const s: ansistring);
procedure execute; override;
end;
constructor tmythread.create(const s: ansistring);
begin
fs:=s+'a';
freeonterminate:=true;
inherited create(true);
end;
procedure tmythread.execute;
begin
sleep(60);
writeln('done');
end;
var
a: array[1..100] of tmythread;
i: longint;
begin
for i:=low(a) to high(a) do
a[i]:=tmythread.create('b');
for i:=low(a) to high(a) do
a[i].resume;
sleep(60);
end.
|