Go language Recognition-1

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.
About the use of the Go language//1. Channels can be cached or without//2. Without caching, either read or write will block//3. With cache, if the cache overflows, it will block//4.make (Chan int,1) and make (chan int) is not the same, the first channel write two data will be blocked, the second write will block//5. If the process is blocking, but the master has exited execution, the program deadlock is considered//6. If the program is in a blocking state other than the main thread (without a co-process), the program is considered to be deadlocked//7. Bottom line: There is only one co-process (which can be the master), in blocking, thinking that the program is in deadlock//8. A subroutine is a special case of a process that blocks until the subroutine executes and returns, and the process may not wait until execution is complete, and then the condition is met and then returned to execute the package mainimport ("FMT") Func Main ()  {//make (chan string,1) and make (Chan string) is not the same as//make (Chan string,1) in the channel buffer is 1//here if you write make (chan String) causes blocking, deadlock, because there is no cached channel, either read or write will block//two solutions, move the push data into written (using GO statement), or increase the cache,//cache does not reach the upper limit, there will be no deadlock situation chan1: = Make ( Chan string,1) func () {fmt. Printf ("push data to channel \ n" in the process); Chan1 <-"Go Bar"} () fmt. Printf ("Data read from channel:%v", <-Chan1)}

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.