Question: 1. Develop a small program where a task is split into subtasks and executed by new threads. The results of the task must be collected
1. Develop a small program where a task is split into subtasks and executed by new threads. The results of the task must be collected in the main thread which will wait for all tasks to complete and all results to be gathered before reporting a final result. If you are stuck for ideas, generate a random number and block in each task, gather the random numbers in the main thread and sum their values.
2. Implement the program in a few different ways to explore the different approaches to sharing data between threads. Few of them for this task are, try using a container in a global variable, try storing values as instance variables, and try using a queue (do not write separate program, just apply these changes on the same program and then comment them so we can view it while marking). Sharing data between threads is central to almost all programs that implement concurrency via the threading module. After applying different approaches, explain the changes/difference you see in the program as comment.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
