Question: Q.No.1. Use Threading and parallel processing Implement given scenario in C# A voting process is going on. Now you have two candidate who voters can

 Q.No.1. Use Threading and parallel processing Implement given scenario in C#

Q.No.1. Use Threading and parallel processing Implement given scenario in C# A voting process is going on. Now you have two candidate who voters can vote for - A and B. Now, the voting process will happen in various localities(cities), and each locality has its voters and a collector who counts the votes. After the collector has collected the votes, he she takes it to a central location (shared among all collectors) to add with whatever is already present in the central box Here the voting process in each locality is like a thread. Each can occur independently without interfering with another. But when the collector comes to add the votes at the central location, he/she needs to synchronize with other collectors who have also come to deposit their count Initially the central bin has count 0 for both A and B. Now collector "X" comes and deposits the following count (A- 10, B- 20). Now collector "Y" and "Z" come in at the same time. "Y" has the count (A- 5, B- 15), and collector "Z" has count (A- 12, B- 8). If both get the value from the bin to add at the same time - then "Y" will add his count to initial (10/20) and even "2" will do the same. Now when they place the new count in the box, it will be erroneous, since atleast one of them would not be having an updated count

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 Mathematics Questions!