Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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 160

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago

Question

Did the team members feel that their work mattered

Answered: 1 week ago

Question

3. What may be the goal of the team?

Answered: 1 week ago