On the official Russian documentation page Golang reported:

The term "concurrency" in programming, apparently, has no exact analogue in Russian. Although many people translate it as "parallelism", this is a mistake (see Parallelism is not concurrency), just as in mathematics "concurrent lines" are not at all "parallel lines", but straight lines having a common point. The Russian language is rubber, it will endure another term: "competitiveness", "competitive".

This remark, however, completely does not reveal the very concept and essence of the phenomenon of this "concurrency". What is it?

Update: Taking into account this issue , I understand that goroutine is NOT executed in parallel (not in geometric, but in the sense of simultaneous execution). Just how it all works and what is meant by this is still not understood.

    2 answers 2

    It means that in some place of the program a “fork” is formed from the threads of the code execution. Those. up to this point, the logical chain was one and sequential, but in this place it splits and two logical chains of sequential actions performed in parallel go on. Further, usually, they merge back, or some branches simply cease to exist having fulfilled their logic.

    Those. the term is sufficiently precise, just an uninitiated person may think within the framework of geometry that once parallel flows, they do not intersect, and this is not quite so. They are not parallel everywhere.

    • > actions performed in parallel. I think you are wrong here. See addition to my question. - Jeremy
    • one
      It seems to me that there are no special contradictions, rather there is an imperfection in the implementation of this functional (or maybe it was intentionally done ...). Those. There is a possibility of threads hanging up if system blocking calls of the type fmt.Prinln are called in them and otherwise everything is - they are executed in parallel, you just need to pay attention to such things, otherwise the thread can stick ... - qnub
    • Do I understand correctly: at a certain point in the execution of the program, a branching has gone: the gorutin and the main code; because All this is done in one system thread / process, then it all works through some kind of internal shaduller, which in turn executes the code from these pseudo-threads? - Jeremy
    • qnub, everything figured out. Thank you for your complicity. - Jeremy

    If we talk about an example from your question, then the problem is that the same routine writes a variable in the infinity loop, while another routine tries to access the same variable (as I see it). If, for example, put a pause in a loop that writes to a variable, then main will display the new value of the variable:

    type myInt struct { Value int64 } func (i *myInt) add(x int64) int64 { i.Value += x return i.Value } func (i *myInt) setValue(x int64) { i.Value = x } func (i *myInt) getValue() int64 { return i.Value } var x myInt func inc_x() { //test for { x.add(1) time.Sleep(1 * time.Nanosecond) } } func main() { go inc_x() for { fmt.Print("x=") fmt.Println(x.getValue()) // time.Sleep(1 * time.Second) } }