---
title: "Nested Invocations"
url: https://docs.zeroc.com/ice/3.8/runtime/threading-model/nested-invocations
language: swift
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Nested Invocations

Programming language: Swift. Other languages: [C++](https://docs.zeroc.com/ice/3.8/runtime/threading-model/nested-invocations/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/runtime/threading-model/nested-invocations/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/threading-model/nested-invocations/java.md), [Python](https://docs.zeroc.com/ice/3.8/runtime/threading-model/nested-invocations/python.md).

A *nested invocation* is an invocation made from a dispatch or from the callback of an asynchronous invocation.

## Deadlocks with Nested Invocations

Nested invocations are common, but they can deadlock. To avoid deadlocks, do not hold a shared resource, such as a mutex or a thread of an [Ice thread pool](https://docs.zeroc.com/ice/3.8/runtime/threading-model/thread-pools/swift.md), while waiting. The rest of this page shows the common case, a nested invocation made from a dispatch; the same rule applies to a callback.

In Swift, a dispatch runs in its own task and a nested invocation is awaited, so waiting holds no thread of an Ice thread pool.

## See Also

- [Thread Pools](https://docs.zeroc.com/ice/3.8/runtime/threading-model/thread-pools/swift.md)
- [Object Adapter Thread Pools](https://docs.zeroc.com/ice/3.8/runtime/threading-model/object-adapter-thread-pools.md)
- [Thread Pool Design Considerations](https://docs.zeroc.com/ice/3.8/runtime/threading-model/thread-pool-design-considerations/swift.md)
- [Oneway Invocations](https://docs.zeroc.com/ice/3.8/runtime/invocation/invocation-mode/oneway-invocations/swift.md)
