thread id of dispatch_get_main_queue()
Is there a开发者_StackOverflow社区 way to find the thread id that is associated with 'dispatch_get_main_queue()'?
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.)
精彩评论