This commit is contained in:
chai2010
2016-01-18 11:14:19 +08:00
parent a91355f5f1
commit 884ada9cd0
20 changed files with 116 additions and 92 deletions

View File

@@ -170,5 +170,5 @@ func icer(iced chan<- *Cake, cooked <-chan *Cake) {
第三種避免數據競爭的方法是允許很多goroutine去訪問變量但是在同一個時刻最多隻有一個goroutine在訪問。這種方式被稱爲“互斥”在下一節來討論這個主題。
練習 9.1: 給gopl.io/ch9/bank1程序添加一個Withdraw(amount int)取款函數。其返迴結果應該要表明事務是成功了還是因爲沒有足夠資金失敗了。這條消息會被發送給monitor的goroutine且消息需要包含取款的額度和一個新的channel這個新channel會被monitor goroutine來把boolean結果發迴給Withdraw。
**練習 9.1** 給gopl.io/ch9/bank1程序添加一個Withdraw(amount int)取款函數。其返迴結果應該要表明事務是成功了還是因爲沒有足夠資金失敗了。這條消息會被發送給monitor的goroutine且消息需要包含取款的額度和一個新的channel這個新channel會被monitor goroutine來把boolean結果發迴給Withdraw。