using System;
using System.Threading;
// Class to perform tasks
class TaskHandler
{
// Method to print numbers
public void PrintNumbers()
{
for (int i = 1; i <= 5; i++)
{
Console.WriteLine($"Number: {i}");
Thread.Sleep(1000); // Simulate some work with a delay
}
}
// Method to print letters
public void PrintLetters()
{
for (char c = 'A'; c <= 'E'; c++)
{
Console.WriteLine($"Letter: {c}");
Thread.Sleep(1000); // Simulate some work with a delay
}
}
}
class Program
{
static void Main()
{
TaskHandler handler = new TaskHandler();
// Create threads for each task
Thread thread1 = new Thread(new ThreadStart(handler.PrintNumbers));
Thread thread2 = new Thread(new ThreadStart(handler.PrintLetters));
// Start the threads
thread1.Start();
thread2.Start();
// Wait for threads to finish
thread1.Join();
thread2.Join();
Console.WriteLine("Both tasks are completed.");
}
}