Skip to content

Commit

Permalink
Add more comments for Q5
Browse files Browse the repository at this point in the history
  • Loading branch information
sikatikenmogne committed May 4, 2024
1 parent dea0be0 commit 75aeaf0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions concurency-workshop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static void Main(string[] args)

Console.WriteLine("Q5 - =======Pool Threads=======");

// Delegate definition for thread execution
DelegateThreadFive delegateThreadFive = (obj) =>
{
String msg = obj.ToString();
Expand All @@ -153,11 +154,14 @@ static void Main(string[] args)
};


// Create and start three parameterized threads
// Create a synchronization event for thread completion
ManualResetEvent mre = new ManualResetEvent(false); // Synchronization event

ThreadPool.QueueUserWorkItem((state) => {
// Queue a task to the thread pool
ThreadPool.QueueUserWorkItem((state) =>
{
// Create and start three parameterized threads
Thread t1 = new Thread(new ParameterizedThreadStart(delegateThreadFive));
t1.Name = "Thread " + delegateThreadFive.Method.Name + " 1";
Expand All @@ -167,10 +171,12 @@ static void Main(string[] args)
Thread t3 = new Thread(new ParameterizedThreadStart(delegateThreadFive));
t3.Name = "Thread " + delegateThreadFive.Method.Name + " 3";
// Start the threads with specific messages as arguments
t1.Start("Maiva-hub");
t2.Start("noumendarryl");
t3.Start("sikatikenmogne");
// Wait for all three threads to finish
t1.Join();
t2.Join();
t3.Join();
Expand Down

0 comments on commit 75aeaf0

Please sign in to comment.