Home / structured vs unstructured concurrency Swift
Swift concurrency
Structured vs unstructured concurrency Swift
This comparison question checks whether you understand how task lifetimes and error propagation work, which is where concurrency bugs hide.
The core difference
Structured concurrency ties child task lifetimes to a scope: async let and withTaskGroup create children that must finish before the scope returns, and errors and cancellation propagate through the tree automatically. Unstructured tasks, created with Task or Task.detached, live independently of the surrounding scope and are not awaited or cancelled for you.
When to use each
Prefer structured concurrency by default because the compiler and runtime manage lifetimes, cancellation, and error propagation for you. Reach for an unstructured Task to bridge from synchronous code, such as kicking off async work from a button handler, and use Task.detached rarely, since it drops the surrounding actor context and cancellation links.
Go deeper than a summary
Share Your Screen works topics like this through in full: 75 solved Swift problems with tests, 9 real case studies, and 7 annotated mock interviews, so you rehearse the live round instead of just reading about it.
Frequently asked
What is unstructured concurrency?
Tasks created with Task or Task.detached that live independently of the current scope, so you are responsible for awaiting, cancelling, and error handling yourself.
When should you use Task.detached?
Rarely. It runs without inheriting the current actor context, priority, or cancellation, so only use it when you explicitly need to break those links.