有没有办法找到与“ dispatch_get_main_queue()”相关联的线程ID?
Any block evaluated on the main queue will evaluate on the thread it is associated with, so you can get the ID of that thread by asking what thread such a block is evaluating on:
#import <mach/mach_init.h>
__block mach_port_t mainThreadID;
dispatch_async(dispatch_get_main_queue(), ^{
mainThreadID = mach_thread_self();
});
(A mach_port_t
is really just an unsigned int.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.