---
title: main
framework: dispatch
role: symbol
role_heading: Type Property
path: dispatch/dispatchqueue/main
---

# main

The dispatch queue associated with the main thread of the current process.

## Declaration

```swift
class var main: DispatchQueue { get }
```

## Discussion

Discussion The system automatically creates the main queue and associates it with your application’s main thread. Your app uses one (and only one) of the following three approaches to execute blocks submitted to the main queue: Calling dispatchMain() Starting your app with a call to UIApplicationMain(_:_:_:_:) (iOS) or NSApplicationMain(_:_:) (macOS) Using a CFRunLoop on the main thread As with the global concurrent queues, calls to suspend(), resume(), dispatch_set_context, and the like have no effect when used on the queue in this property. important: If the main thread is unresponsive for too long, it can lead to a 0x8badf00d exception with the main thread at mach_msg_trap. On iOS, this exception may be raised if the watchdog mechanism detects that your app failed to respond to certain user interface events in time. The iOS watchdog exists in order to keep the user interface responsive. If your app has a long running task, such as making network call, run it on a global system queue, or on another background dispatch queue. Alternatively, use asynchronous versions of the call, if available.

## See Also

### Creating a Dispatch Queue

- [global(qos:)](dispatch/dispatchqueue/global(qos:).md)
- [init(label:qos:attributes:autoreleaseFrequency:target:)](dispatch/dispatchqueue/init(label:qos:attributes:autoreleasefrequency:target:).md)
- [DispatchQoS.QoSClass](dispatch/dispatchqos/qosclass-swift.enum.md)
- [DispatchQueue.Attributes](dispatch/dispatchqueue/attributes.md)
- [DispatchQueue.AutoreleaseFrequency](dispatch/dispatchqueue/autoreleasefrequency.md)
- [OS_dispatch_queue_main](dispatch/os_dispatch_queue_main-swift.class.md)
- [OS_dispatch_queue_global](dispatch/os_dispatch_queue_global-swift.class.md)
- [DispatchSerialQueue](dispatch/dispatchserialqueue.md)
- [DispatchConcurrentQueue](dispatch/dispatchconcurrentqueue.md)
- [dispatch_queue_main_t](dispatch/dispatch_queue_main_t.md)
- [dispatch_queue_global_t](dispatch/dispatch_queue_global_t.md)
- [dispatch_queue_serial_t](dispatch/dispatch_queue_serial_t.md)
- [dispatch_queue_concurrent_t](dispatch/dispatch_queue_concurrent_t.md)
