pascalabcnet/TestSuite/CompilationSamples/Mutual Lock.pas
andrewlord607 3a7551d0a2 merge fix
2017-05-30 23:58:34 +03:00

33 lines
842 B
ObjectPascal

// Демонстрация использования критических секций и возможных взаимоблокировок
begin
{$omp parallel sections}
begin
begin
WriteLn('Thread 1 started');
{$omp critical a}
begin
Writeln('Lock a set by 1 thread');
//ReadLn;
{$omp critical b}
begin
Writeln('Lock b set by 1 thread');
end;
end;
WriteLn('Thread 1 finished');
end;
begin
WriteLn('Thread 2 started');
{$omp critical b}
begin
Writeln('Lock b set by 2 thread');
//ReadLn;
{$omp critical a}
begin
Writeln('Lock a set by 2 thread');
end;
end;
WriteLn('Thread 2 finished');
end;
end;
Writeln('Program finished without mutual lock!');
end.