Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View file

@ -0,0 +1,20 @@
uses System, System.Threading, System.Threading.Tasks;
procedure Worker(arg: SemaphoreSlim; id: integer);
begin
var sem: SemaphoreSlim := arg;
sem.Wait();
Writeln('Thread ', id, ' has a semaphore & is now working.');
Thread.Sleep(2 * 1000);
Writeln('#', id, 'done.');
sem.Release();
end;
begin
var semaphore := new SemaphoreSlim(Environment.ProcessorCount * 2, MaxInt);
Writeln('You have ', Environment.ProcessorCount, ' processors availiabe');
Writeln('This program will use ', semaphore.CurrentCount, ' semaphores.');
Parallel.For(0, Environment.ProcessorCount * 3, y -> Worker(semaphore, y));
end.