Golang Chan bug on Windows

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Because the job needs to write a Test Chan's code found that the same code on the Windows run results and Linux results are not the same

Testto Project Main.gopackage mainimport ("FMT" "Time") Var ch chan intfunc Main () {ch = make (chan int, 1) var i inti = 1g o F1 () for J: = 0; J < 10; J + + {time. Sleep (time. Second * 1) fmt. Println ("main") ch <-II = <-ch}}func F1 () {var I inti = 1for {i = <-chfmt. Println (i) time. Sleep (time. Second * 4) ch <-i}}

The results of the compilation run under Windows are as follows


The results of the Linux compilation run are as follows


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.