# Guaranteeing an actor executes off the main thread

**URL:** <https://forums.swift.org/t/guaranteeing-an-actor-executes-off-the-main-thread/75009>\
**Category:** Using Swift\
**Created:** [September 29, 2024, 12:06am UTC](https://forums.swift.org/t/guaranteeing-an-actor-executes-off-the-main-thread/75009 "2024-09-29T00:06:57Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nkbelov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nkbelov/32/34617_2.png) [@nkbelov](https://forums.swift.org/u/nkbelov)\
**Post date:** [September 29, 2024, 1:21am UTC](https://forums.swift.org/t/guaranteeing-an-actor-executes-off-the-main-thread/75009/2 "2024-09-29T01:21:00Z")

</div>

Every actor which is not the main actor executes on a background thread; this is actually a public guarantee and is stated in the documentation: [Actor | Apple Developer Documentation](https://developer.apple.com/documentation/swift/actor). More specifically, if an actor doesn't specify a custom executor, it's given a default executor instance, which simply delegates to that background thread pool.

I think you're assuming that an actor becomes "bound" to whatever place it has been created in, but this is not true; an actor is always its own isolation domain regardless of whether its initializer got called by something running on the main actor or not, and because it _already is concurrency-safe_, it can execute concurrently with its creator — through using the global threadpool.

> [@George](#):
>
> Is there consensus on what is the correct approach?

The good news is that you don't have to do anything 🙂 Looks like you want precisely the default behaviour.

* * *

Also, priority is a property of a _task_, not an actor. That is, if you call the same actor method twice from tasks with different priorities, like so:

```swift
func foo() async {
    let myActor = MyActor()
    
    Task(priority: .high) {
        await myActor.synchronousFunction(1)
    }
    
    Task(priority: .low) {
        await myActor.synchronousFunction(2)
    }
}

```

it only affects the scheduling order of the calls, but never "infects" the actor for the rest of its lifetime.

---

_[View the full topic](https://forums.swift.org/t/guaranteeing-an-actor-executes-off-the-main-thread/75009)._
