GCD 创建相同 Label 名称的线程,会造成冲突吗?

2021-01-30 09:25:21 +08:00
 James369
使用 GCD 创建 2 个相同 label 名称的线程,比如:
```swift
let q1 = DispatchQueue(label: "xxx")
let q2 = DispatchQueue(label: "xxx")
```

甚至指向同一变量的名称:
```swift
let name = "xxx"
let q1 = DispatchQueue(label: name)
let q2 = DispatchQueue(label: name)
```

那么 q1 和 q2 会产生关联吗,它们还是独立的吗?
2286 次点击
所在节点    iDev
16 条回复
pipasese
2021-01-30 09:47:03 +08:00
不会,可以把它当做 queue 的一个属性
sinv
2021-01-30 10:09:41 +08:00
GCD 是什么?共产党 /鬼吹灯 /骨传导 /滚床单???
sinv
2021-01-30 10:12:27 +08:00
GCD 是什么?某产党 /鬼吹灯 /骨传导 /滚床单 /Google Cloud Driver ???
LMkillme
2021-01-30 10:12:40 +08:00
@sinv 大中枢并发(Grand Central Dispatch)
sinv
2021-01-30 10:15:47 +08:00
@LMkillme 谢谢你,这么说我就看懂了。
James369
2021-01-30 10:22:14 +08:00
@sinv 这是专业名词,知道的自然懂
sinv
2021-01-30 10:27:46 +08:00
@James369 #6 有够专业,嗯棒棒的,请多多指导。
icyalala
2021-01-30 10:44:15 +08:00
@sinv 这是 iDev 节点。
对于 iOS 开发来说,GCD 是一个苹果官方使用的专有名词:
https://developer.apple.com/documentation/dispatch
hxndg
2021-01-30 11:10:35 +08:00
先预览看看,然后类型选择了 markdown 了吗?
oxromantic
2021-01-30 11:33:55 +08:00
人家属性就说了叫 label,你还不允许系统创建两个一样 label 的按钮文本框啥的么
chiaf
2021-01-30 12:04:55 +08:00
语法高亮用错了,
```
print("Hello")
```
反引号 * 3
代码
反引号 * 3
Building
2021-01-30 13:35:00 +08:00
函数这样设计的话明显不会啊,如果会的话就叫 dequeueFromReusePool 了,有的直接返回,没有创建新的,跟 TableViewCell 一样。
Building
2021-01-30 13:35:57 +08:00
函数这样设计的话明显不会啊,如果会的话就叫 dequeueFromReusePool 了,有的直接返回,没有创建新的,跟 TableViewCell 一样,除非文档特别说明不能创建两个相同名称的线程。
MrKrabs
2021-01-30 14:54:43 +08:00
label
A string label to attach to the queue to uniquely identify it in debugging tools such as Instruments, sample, stackshots, and crash reports. Because applications, libraries, and frameworks can all create their own dispatch queues, a reverse-DNS naming style (com.example.myqueue) is recommended. This parameter is optional and can be NULL.
shawndev
2021-02-01 17:31:21 +08:00
能传 NULL 的参数一般都允许重复
arnoldxiao
2021-02-18 13:47:39 +08:00
这不就是获取的同一个队列?和线程并无直接关系

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/749771

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX