lazarus/components/multithreadprocs/examples/simplemtp1.lpr
mattias 96d9a3c292 added mtprocs
git-svn-id: trunk@38214 -
2012-08-09 17:02:12 +00:00

24 lines
440 B
ObjectPascal

program SimpleMTP1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads, cmem,
{$ENDIF}
MTProcs;
// a simple parallel procedure
procedure DoSomethingParallel(Index: PtrInt; Data: Pointer; Item: TMultiThreadProcItem);
var
i: Integer;
begin
writeln(Index);
for i:=1 to Index*1000000 do ; // do some work
end;
begin
ProcThreadPool.DoParallel(@DoSomethingParallel,1,5,nil); // address, startindex, endindex, optional data
end.