Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1c6f44c

Browse files
committedAug 30, 2022
Add to PW
1 parent 7eb83ce commit 1c6f44c

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
 
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<RootNamespace>_2022._08._26_PW_Part_III</RootNamespace>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
11+
</Project>

‎2022.08.26_PW_Part_III/Program.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace _2022._08._26_PW_Part_III
2+
{
3+
internal class Program
4+
{
5+
static void Main()
6+
{
7+
List<Thread> threads = new();
8+
for (int i = 0; i < 10; i++)
9+
{
10+
threads.Add(new(ShowRandomNumbers) { Name = $"Lists thread {i}" });
11+
}
12+
Semaphore semaphore = new(3, 3);
13+
foreach (Thread thread in threads)
14+
{
15+
thread.Start(semaphore);
16+
}
17+
}
18+
19+
static void ShowRandomNumbers(object? obj)
20+
{
21+
Semaphore? semaphore = obj as Semaphore;
22+
semaphore?.WaitOne();
23+
try
24+
{
25+
Random random = new();
26+
int[] nums = new int[3] { random.Next(0, 101), random.Next(0, 101), random.Next(0, 101) };
27+
Console.WriteLine($"Поток {Environment.CurrentManagedThreadId} выводит числа {nums[0]}, {nums[1]} и {nums[2]}");
28+
Thread.Sleep(500);
29+
}
30+
finally
31+
{
32+
semaphore?.Release();
33+
}
34+
35+
}
36+
}
37+
}

‎System_Programming_Course.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2022.08.26_PW", "2022.08.26
3030
EndProject
3131
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2022.08.26_PW_Part_II", "2022.08.26_PW_Part_II\2022.08.26_PW_Part_II.csproj", "{FB169683-5EB6-447E-905E-911E0C0EAEC9}"
3232
EndProject
33+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2022.08.26_PW_Part_III", "2022.08.26_PW_Part_III\2022.08.26_PW_Part_III.csproj", "{A1040FF4-5BC9-42FA-9E09-E402444E5AF2}"
34+
EndProject
3335
Global
3436
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3537
Debug|Any CPU = Debug|Any CPU
@@ -80,6 +82,10 @@ Global
8082
{FB169683-5EB6-447E-905E-911E0C0EAEC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
8183
{FB169683-5EB6-447E-905E-911E0C0EAEC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
8284
{FB169683-5EB6-447E-905E-911E0C0EAEC9}.Release|Any CPU.Build.0 = Release|Any CPU
85+
{A1040FF4-5BC9-42FA-9E09-E402444E5AF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
86+
{A1040FF4-5BC9-42FA-9E09-E402444E5AF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
87+
{A1040FF4-5BC9-42FA-9E09-E402444E5AF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
88+
{A1040FF4-5BC9-42FA-9E09-E402444E5AF2}.Release|Any CPU.Build.0 = Release|Any CPU
8389
EndGlobalSection
8490
GlobalSection(SolutionProperties) = preSolution
8591
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)
This repository has been archived.