Using multiple Goroutines on Go Tour Equivalent Binary Trees -


The problem in the go tour is to use a clear solution when trying to solve the pedestrian part. Other solutions, such as a closing, are given in response to the way to solve the problem.

My original idea was to use a gorotin for each stage of walking. Is not it better, and more gonci (what is equal to the feet of Pyongi?) What is the solution? The problem is that I could not understand how a) shutting down the channel after closing the channel, or b) indicate in some other way that the tree was completed by walking. Already 2 channels are used, one for the data and one for leaving the signal. Passing the second channel is not fit with the definition of the problem, and the basic issue of running finish is still present. Is there a fantastic solution for every step to move with a gorotine, or is the best solution recursive?

  func walk (t * tree.Tree, ch chan int) {if t! = Nil {Go Walk (T. Left, CA) CA LT; T. Value go talk (T. Wright, CH)} // This is done with the node, how do I know when everything is done? Using a gourdine for each step of the walk will not work.  

  go fmt.println (1) go fmt.println (2) go fmt.println (3)  

123 , Print out any of 132, 213, 231, 312, or 321, depending on how the scheduler runs those gorintins. This means that your running implementation is no longer giving you value in the right order.

When you really want to do something, gorotines are the only correct answers; Given that the output should be strictly ordered by the channel, there is no concurrency to take advantage of this problem.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -