Skip to content

Instantly share code, notes, and snippets.

@JohnPeel

JohnPeel/output Secret

Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnPeel/39afeac6491d264a0816 to your computer and use it in GitHub Desktop.
Save JohnPeel/39afeac6491d264a0816 to your computer and use it in GitHub Desktop.
Compiled successfully in 688 ms.
6036 was here...
5920 was here...
6108 was here...
4796 was here...
5684 was here...
180 was here...
5792 was here...
5472 was here...
5284 was here...
4216 was here...
Successfully executed.
program new;
{$loadlib libthread}
var
x: string;
section: TCriticalSection;
procedure Test(Thread: TThread; Data: Pointer); native;
begin
section.Acquire();
x := x + IntToStr(Thread.getThreadID()) + ' was here...'#13#10;
section.Release();
end;
var
ThreadPool: array[0..9] of TThread;
I: LongInt;
begin
x := '';
section.Init()
for I := 0 to 9 do
begin
ThreadPool[I].Init(Test, nil);
ThreadPool[I].Start()
end;
//Waiting...
for I := 0 to 9 do
begin
ThreadPool[I].WaitFor();
ThreadPool[I].Free()
end;
section.Free();
WriteLn(x);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment