This commit is contained in:
github-actions[bot]
2025-07-28 04:56:46 +00:00
parent 26da315c57
commit a08e171516
128 changed files with 149 additions and 527 deletions

View File

@@ -528,7 +528,7 @@
<div class="sidetoc"><nav class="pagetoc"></nav></div>
<main>
<ul dir="auto"><li><em>凹语言(Go实现, 面向WASM设计): <a href="https://github.com/wa-lang/wa">https://github.com/wa-lang/wa</a></em></li><li><em>WaBook(Go语言实现的MD电子书构建工具): <a href="https://github.com/wa-lang/wabook">https://github.com/wa-lang/wabook</a></em></li></ul><hr>
<ul dir="auto"><li><em>凹语言(Go实现, 面向WASM设计): <a href="https://github.com/wa-lang/wa">https://github.com/wa-lang/wa</a></em></li><li><em>《Go语言高级编程》: <a href="https://github.com/chai2010/advanced-go-programming-book">https://github.com/chai2010/advanced-go-programming-book</a></em></li></ul><hr>
<h2>9.4. 内存同步</h2>
<p>你可能比较纠结为什么Balance方法需要用到互斥条件无论是基于channel还是基于互斥量。毕竟和存款不一样它只由一个简单的操作组成所以不会碰到其它goroutine在其执行“期间”执行其它逻辑的风险。这里使用mutex有两方面考虑。第一Balance不会在其它操作比如Withdraw“中间”执行。第二更重要的是“同步”不仅仅是一堆goroutine执行顺序的问题同样也会涉及到内存的问题。</p>