V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
James369
V2EX  ›  iDev

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

  •  
  •   James369 · 2021-01-30 09:25:21 +08:00 · 2272 次点击
    这是一个创建于 1181 天前的主题,其中的信息可能已经有所发展或是发生改变。
    使用 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 会产生关联吗,它们还是独立的吗?
    第 1 条附言  ·  2021-01-30 10:21:24 +08:00
    顺便问下,加了 markdown 语法,怎么还是无法语法高亮。。
    16 条回复    2021-02-18 13:47:39 +08:00
    pipasese
        1
    pipasese  
       2021-01-30 09:47:03 +08:00 via iPhone   ❤️ 1
    不会,可以把它当做 queue 的一个属性
    sinv
        2
    sinv  
       2021-01-30 10:09:41 +08:00 via Android
    GCD 是什么?共产党 /鬼吹灯 /骨传导 /滚床单???
    sinv
        3
    sinv  
       2021-01-30 10:12:27 +08:00 via Android
    GCD 是什么?某产党 /鬼吹灯 /骨传导 /滚床单 /Google Cloud Driver ???
    LMkillme
        4
    LMkillme  
       2021-01-30 10:12:40 +08:00
    @sinv 大中枢并发(Grand Central Dispatch)
    sinv
        5
    sinv  
       2021-01-30 10:15:47 +08:00 via Android
    @LMkillme 谢谢你,这么说我就看懂了。
    James369
        6
    James369  
    OP
       2021-01-30 10:22:14 +08:00
    @sinv 这是专业名词,知道的自然懂
    sinv
        7
    sinv  
       2021-01-30 10:27:46 +08:00 via Android
    @James369 #6 有够专业,嗯棒棒的,请多多指导。
    icyalala
        8
    icyalala  
       2021-01-30 10:44:15 +08:00   ❤️ 1
    @sinv 这是 iDev 节点。
    对于 iOS 开发来说,GCD 是一个苹果官方使用的专有名词:
    https://developer.apple.com/documentation/dispatch
    hxndg
        9
    hxndg  
       2021-01-30 11:10:35 +08:00
    先预览看看,然后类型选择了 markdown 了吗?
    oxromantic
        10
    oxromantic  
       2021-01-30 11:33:55 +08:00 via iPhone
    人家属性就说了叫 label,你还不允许系统创建两个一样 label 的按钮文本框啥的么
    chiaf
        11
    chiaf  
       2021-01-30 12:04:55 +08:00
    语法高亮用错了,
    ```
    print("Hello")
    ```
    反引号 * 3
    代码
    反引号 * 3
    Building
        12
    Building  
       2021-01-30 13:35:00 +08:00 via iPhone
    函数这样设计的话明显不会啊,如果会的话就叫 dequeueFromReusePool 了,有的直接返回,没有创建新的,跟 TableViewCell 一样。
    Building
        13
    Building  
       2021-01-30 13:35:57 +08:00 via iPhone
    函数这样设计的话明显不会啊,如果会的话就叫 dequeueFromReusePool 了,有的直接返回,没有创建新的,跟 TableViewCell 一样,除非文档特别说明不能创建两个相同名称的线程。
    MrKrabs
        14
    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
        15
    shawndev  
       2021-02-01 17:31:21 +08:00
    能传 NULL 的参数一般都允许重复
    arnoldxiao
        16
    arnoldxiao  
       2021-02-18 13:47:39 +08:00
    这不就是获取的同一个队列?和线程并无直接关系
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5426 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:08 · PVG 17:08 · LAX 02:08 · JFK 05:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.