If you haven't studied concurrency before, I can't recommend any tutorials.
To start to learn about concurrency, I'd first recommend _some_
reading and theoretical background.
Concurrency is a complex concept. A "10x" multiplier estimation
compared to e.g. structured programming is probably
Is there a recommended tutorial?
在 2019年3月1日星期五 UTC+8下午12:21:58,Robert Engels写道:
>
> I think it would be helpful if you learned more about concurrent
> programming. It is 10x harder, even with the simplifications that Go
> offers. If you don’t understand the concepts you are going to struggle.
I think it would be helpful if you learned more about concurrent programming.
It is 10x harder, even with the simplifications that Go offers. If you don’t
understand the concepts you are going to struggle. Start with some tutorials
and work your way up.
> On Feb 28, 2019, at 10:14 PM,
This is the stack information printed when blocking, how to see which G
blocking program?
SIGABRT: abort
PC=0x7fff9ceabbf2 m=0 sigcode=0
goroutine 0 [idle]:
runtime.pthread_cond_wait(0x1967620, 0x19675e0, 0x7fff)
/usr/local/go/src/runtime/sys_darwin.go:302 +0x51
Sameer is correct, but to be clear - The *block* happens because the
channel is empty, so the receive operation blocks forever. This happens in
both of the cases you show.
The *deadlock* happens because *all* goroutines are blocked and none can
continue. So if you start some other goroutine
The deadlock happens because the channel is empty, so the receive operation
blocks forever.
The second version imports a package that may start new goroutines in its
init functions. If so, those goroutines may not be deadlocked, but the main
function is still blocked on the receive operation.
It
ok, thanks!
在 2019年2月28日星期四 UTC+8下午5:49:48,Jan Mercl写道:
>
> On Thu, Feb 28, 2019 at 10:20 AM > wrote:
>
> Please do not post colorized source code, particularly not using low
> contrast, inverted color schemes. There are people not able to read it.
> Some others may just ignore it or even
On Thu, Feb 28, 2019 at 10:20 AM wrote:
Please do not post colorized source code, particularly not using low
contrast, inverted color schemes. There are people not able to read it.
Some others may just ignore it or even consider it bad netiquette.
Black on white is the most universally readable
dead lock:
package main
import (
"fmt"
// _ "github.com/go-sql-driver/mysql"
)
func main() {
c1 := make(chan int, 10)
fmt.Println(<-c1)
}
block:
package main
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
)
func main() {
c1 := make(chan int, 10)