Go是一种并发语言。这是什么意思?

huangapple go评论83阅读模式
英文:

`Go is a concurrent lang` What does this mean?

问题

Go是一种并发语言。这是什么意思?

这难道不意味着它是C/C++/Java的替代品吗?

英文:

Go is a concurrent lang What does this mean?

doesn't this mean that it is a C/C++/Java.. alternative?

答案1

得分: 7

一个并发语言是指具有并发语言结构的语言。

Go是一种并发语言,因为它有"goroutines"。

> ### 并发
>
> Go提供了goroutines,它是一种轻量级的小线程;这个名字暗示了协程。Goroutines可以通过匿名或命名函数的go语句创建。
>
> Goroutines与其他goroutines并行执行,包括它们的调用者。它们不一定在单独的线程中运行,但一组goroutines会被多个线程复用 - 通过在发送或接收通道消息时阻塞它们来在它们之间移动执行控制。

英文:

A concurrent language is a language that has language constructs for concurrency.

Go is a concurrent language because it has "goroutines".

> ### Concurrency
>
> Go provides goroutines, small lightweight threads; the name alludes to coroutines. Goroutines are created with the go statement from anonymous or named functions.
>
> Goroutines are executed in parallel with other goroutines, including their caller. They do not necessarily run in separate threads, but a group of goroutines are multiplexed onto multiple threads — execution control is moved between them by blocking them when sending or receiving messages over channels.

答案2

得分: 4

这意味着它是一种适合并发(并行,多线程等)编程的语言。它具有特殊的语言结构来支持这种类型的编程。并发编程可以在其他语言(C/C++,Java等)中完成,但可能会更困难,并且程序中可能会出现更多的错误。

英文:

It means that it is a language with features suitable for concurrent (parallel, multithreaded, etc) programming. It has special languge constructs to support this type of programming. Concurrent programming can be done in other languages (C/C++, Java, etc) but it will (arguably) be harder and will probably result in more errors in the programs.

答案3

得分: 1

以下是一些关于并发编程的资源,来自Go编程语言的一些主要作者。

并发编程简介

关于贝尔实验室CSP风格线程编程的资源

英文:

Here are some resources about concurrent programming from some of the principal authors of the Go programming language.

Introduction to Concurrent Programming

Resources about threaded programming in the Bell Labs CSP style

huangapple
  • 本文由 发表于 2011年2月12日 21:25:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/4978274.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定