Question: Q1. Threads in C#: Develop Console Application in C# to work on threads. Consider the given description and methods below. In this question, you need

Q1. Threads in C#: Develop Console Application in C# to work on threads. Consider the given description and methods below. In this question, you need to implement necessary Thread related operations on the given code. In this question first you need to create a list of Fibonacci series.

Then, two methods (public static void) named as thread1() and thread2() were created to work simultaneously.

thread1() will output the first 10 elements of the Fibonacci series.

Call the method to create a list of Fibonacci elements: CreateFibSeries();

Output the content of list. (wait for half a second (0.5 seconds) before showing each element on Console)

thread2() will output the first 10 elements of the Fibonacci series in reverse order.

Reverse the content of list.

Output the reversed content. (wait for half a second before showing each element on Console)

In the main method: Create two threads as t1 and t2 to run methods thread1 and thread2, respectively. Start t1. Then, suspend the main thread for 10 seconds (In other words, your program will wait for 10 seconds). After that, start t2

This is a sample code;

Q1. Threads in C#: Develop Console Application in C# to work on

class Program class Container { // A container class acts as a generic holder. Define a list to hold fibonacci numbers. public static List fibseries = new List(); 1/In all methods below, we can reach this list by using Container.fibseries } public static void CreateFibSeries() 1/This method is used to create a list including first 10 elements of fibonacci series { int i; 1/Add first to elements of fibonacci series and 1 to the list. Container.fibseries.Add(); Container.fibseries.Add(1); 1/Starting from 2nd index, insert the other elements of fibonacci in the list. for (i = 2; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!