use a synchronization mechanism such as a lock or channel communication to establish a relative orde

Posted yuanjiangw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了use a synchronization mechanism such as a lock or channel communication to establish a relative orde相关的知识,希望对你有一定的参考价值。

https://golang.org/ref/mem#tmp_6

 

Goroutine destruction

The exit of a goroutine is not guaranteed to happen before any event in the program. For example, in this program:

var a string

func hello() {
	go func() { a = "hello" }()
	print(a)
}

the assignment to a is not followed by any synchronization event, so it is not guaranteed to be observed by any other goroutine. In fact, an aggressive compiler might delete the entire go statement.

If the effects of a goroutine must be observed by another goroutine, use a synchronization mechanism such as a lock or channel communication to establish a relative ordering.

Channel communication

Channel communication is the main method of synchronization between goroutines. Each send on a particular channel is matched to a corresponding receive from that channel, usually in a different goroutine.

以上是关于use a synchronization mechanism such as a lock or channel communication to establish a relative orde的主要内容,如果未能解决你的问题,请参考以下文章

MEC — 安全策略

MEC — 安全策略

ETSI MEC — 与 5G 的融合

MEC与C-V2X融合应用场景白皮书

5G UPF + MEC 的部署位置场景与模式

《多接入边缘计算(MEC)及关键技术》读书笔记 | 第4章 基于MEC的本地分流技术