Question
please use C# using System; using System.Threading; namespace ConsoleApplication1 { // Simple Threading Examples - 4 // Using Threads to find of the sum of
please use C#
using System; using System.Threading;
namespace ConsoleApplication1 { // Simple Threading Examples - 4 // Using Threads to find of the sum of numbers 0-100 class Program { public static int[] anarray = { 2, 3, 12, 15, 0, 4, 7, 9, 2, 7 }; public static int sum = 0;
static void myThreadMethod(object myarray) { // a[0] will be the threadid and a[1] will be the size of the numbers added int[] a = new int[2]; a = (int[])myarray;
int threadid = a[0]; int size = a[1];
for (int i = threadid * size ; i
static void Main(string[] args) { //Assume that the number and the processor numbers are given as: int p = 5; int n = anarray.Length; int size = n / p;
Thread[] t = new Thread[p];
for(int i=0;i for (int i = 0; i Console.WriteLine("result:{0}", sum); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started