lazarus-ccr/components/multithreadprocs/examples/simplemtp1.lpr
mgaertner 91b301ae80 multithreadprocs: added examples
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@694 8e941d3f-bd1b-0410-a28a-d453659cc2b4
2009-02-03 08:41:40 +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.