What is the main thread in GCD?

What exactly is the main thread in Grand Central Dispatch? Is it a thread created when the program starts up (maybe just before the main() function gets called), which is arbitrarily called "the main thread"? Or is it the program's main execution flow, which is always created for every running process? I think the first option is the right one, because it's not possible to send blocks to be executed by the program's main execution flow, I guess, unless this is done explicitly. So, the main thread in GCD must be another thread that is created to wait for blocks to be executed. Is it right?


GCD has no main thread unless running in the context of a CF/Foundation based process that has one of its own. If you use dispatch_main there's no main thread.

Every UI application on OS X has a main thread - it's where UI updates are (and must be) performed. GCD associates a queue with this thread, the main queue, and is also free to execute blocks from other queues on this thread though, in practice, it generally creates other threads for this purpose as it is generally considered inadvisable to block the main thread for any length of time (doing so brings up the dreaded SPOD, or spinning pizza of death, cursor).

Calling dispatch_main() also does not destroy or obviate the need for a main thread, it simply blocks it (which is why UI apps should use the run loop instead).

Need Your Help

The difference between null and empty string in .net

c# .net

Trying to figure this out and couldn't find the answer anywhere. If i have a string and i split it in the spaces, like:

Can a JPA entity have multiple OneToMany associations?

java hibernate jpa orm hibernate-mapping

Adding two OneToMany associations to my entity class seems not to work. It works fine if I remove one of them.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.