Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Go language Homework help A series of numbers in a slice must be processed and the results displayed. The processing is performed by calling the
Go language Homework help
A series of numbers in a slice must be processed and the results displayed. The processing is performed by calling the process function. In order to accelerate the processing, it is decided to create a separate thread for each number to be processed. Here is the first version of this program : package main import "fmt" import "sync" import "time" func process (v int) int { time. Sleep (1500*time. Millisecond) // simulate compute time return 2* } func main() { var wg sync.WaitGroup for , value := range [lint{9,35,27,56,88,80} { wg. Add (1) go func() { defer wg. Done () fmt. Println (process (value)) } () } wg. Wait() } Unfortunately, the results obtained are not the ones expected... Malheureusement, le rsultat obtenu n'est pas celui attendu... 160 160 160 160 160 160 Correct the problem by making few modifications to the program (not more than three two or four lines). The result should be as below (the display order is not important). 176 70 112 18 54 160Step 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