Yes! This is perfect!

On Friday, November 30, 2018 at 2:52:57 PM UTC-8, Justin Israel wrote:
>
>
>
> On Sat, Dec 1, 2018, 10:43 AM Alex Dvoretskiy <advore...@gmail.com 
> <javascript:>> wrote:
>
>> Here is recursion. I d'ont know when its end.
>>
>
> Do you mean that you want to wait for all 3 goroutines to complete? 
>
> var wg sync.WaitGroup
> wg.Add(3)
>
> go func() {
>     inOrderTr(root)
>     wg.Done()
> }() 
>
> go func() {
>     preOrderTr(root)
>     wg.Done()
> }() 
>
> go func() {
>     postOrderTr(root)
>     wg.Done()
> }() 
>
> wg.Wait()
>
>
>> On Friday, November 30, 2018 at 12:04:42 PM UTC-8, Burak Serdar wrote:
>>>
>>> On Fri, Nov 30, 2018 at 12:44 PM Alex Dvoretskiy 
>>> <advore...@gmail.com> wrote: 
>>> > 
>>> > Hi, 
>>> > 
>>> > How should I modify my code if I want to run three recursive functions 
>>> in parallel? 
>>> > 
>>> > go inOrderTr(root) 
>>> > go preOrderTr(root) 
>>> > go postOrderTr(root) 
>>>
>>> Those three are mutually independent, and the tree is read-only, so 
>>> you don't need any synchronization between the three. You might use a 
>>> sync.WaitGroup to wait for all of them to end. 
>>> > 
>>> > https://play.golang.org/p/n-QLR7V0H49 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com. 
>>>
>> > For more options, visit https://groups.google.com/d/optout. 
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to