Skip to content

Commit d82f4a0

Browse files
authored
Merge pull request #1 from kingdom365/kingdom365-patch-1
Update concurrent-model.md
2 parents 0f56806 + bad6126 commit d82f4a0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

docs/golang/core/concurrent/concurrent-model.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ func producer(id int, jobs chan<- int, wg *sync.WaitGroup) {
289289

290290
// 消费者函数从通道接收数据并处理
291291
func consumer(id int, jobs <-chan int, wg *sync.WaitGroup) {
292-
defer wg.Done()
293292
for j := range jobs {
294293
fmt.Printf("Consumer %d processing job %d\n", id, j)
295294
time.Sleep(time.Second)
@@ -308,7 +307,6 @@ func main() {
308307

309308
// 启动消费者 Goroutine
310309
for c := 1; c <= 2; c++ {
311-
wg.Add(1)
312310
go consumer(c, jobs, &wg)
313311
}
314312

@@ -318,4 +316,4 @@ func main() {
318316
}
319317
```
320318

321-
这些并发模式提供了一种结构化的方法来编写并发程序,通过合理使用这些模式,可以简化并发编程的复杂性,提高代码的可维护性和扩展性。
319+
这些并发模式提供了一种结构化的方法来编写并发程序,通过合理使用这些模式,可以简化并发编程的复杂性,提高代码的可维护性和扩展性。

0 commit comments

Comments
 (0)