Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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#

image text in transcribed

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); } } }

Check/Download the class work code, Assignment2SampleCode.txt from elearn and use it for the questions below. Submit your assignment through Elearn/Dropbox. Any different form of submission except ELEARN will not be considered. Given the serial code that adds two vectors, convert the code into a parallel program and use it to find the sum of the elements of the array given in the code. Submit your code. (20 Points) 1. // given the arrays int[ a- (4, 3, 1, 6, 8, 9, 1ee, 23, 13, 44, 14, 67, 89, 34, 23, 69, 1ee, 65, 32, 33, 4 ,5 ,6,18 b: nt b-( 1, 7, 8, 4, 9, 12, 1e, 3, 1, 14, 7, 7, 9, 3, 3, 6, 11, 165, 2, 1, 14, 15, 8, 33) intlc- new int[a.Length] /I adds every item of the array to the sum for (int 0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Window Functions For Data Analysis And Beyond

Authors: Itzik Ben Gan

2nd Edition

0135861446, 978-0135861448

More Books

Students also viewed these Databases questions

Question

What are the need and importance of training ?

Answered: 1 week ago

Question

What is job rotation ?

Answered: 1 week ago