Skip to content

Commit 722bd04

Browse files
committed
describe thread safety of 'map'
1 parent ead21b1 commit 722bd04

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ebook/02.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ slice有一些简便的操作
400400
- `map`的长度是不固定的,也就是和`slice`一样,也是一种引用类型
401401
- 内置的`len`函数同样适用于`map`,返回`map`拥有的`key`的数量
402402
- `map`的值可以很方便的修改,通过`numbers["one"]=11`可以很容易的把key为`one`的字典值改为`11`
403+
- `map`和其他基本型别不同,它不是thread-safe,在多个go-routine存取时,必须使用mutex lock机制
403404

404405
`map`的初始化可以通过`key:val`的方式初始化值,同时`map`内置有判断是否存在`key`的方式
405406

0 commit comments

Comments
 (0)