Thread safety question for property on @ObservableObject

I have a question about how the following would behave, and if it's safe.

in the following scenario... would initialFetch....
a) always be toggled once to False?
b) would the thing that toggles it always be the first task to initialize a MyFeedItem?

because if each task in executing on some unknown thread, could two of these complete the initialization of MyFeedItem at the same time?

class Feed: ObservableObject {
    var initialFetch = True
    @Published var items = [FeedItem]()


    func fetchFeed() async {
        // fetches a list of feed items from API
        feedItems.forEach { [itemInResponse]
            Task {
                 // async creates feed items because we do not care about an item until the image is fetched (in 
                 // the MyFeedItem init
                 let myItem = await MyFeedItem(...)
                 // HERE IS THE QUESTION
                 if initialFetch {
                     initialFetch.toggle()
                     await initialFetchDependentUILogic(item: myItem)
                 }
                 await addItem(item)
            }
        }
    }

    @MainActor
    func addItem(_ item: FeedItem) async {
        items.append(item)
    }
    
    @MainActor
    func initialFetchDependentUILogic(item: FeedItem) {
        // logic that changes UI
    }

}

I'm a bit confused about your question & code, but here are the guiding principles that should help you understand the expected behaviour:

Yes, each Task, unless defined in the scope of an actor, will run on an arbitrary background thread. This means there is no guarantee that your check of initialFetch won't be executed concurrently, i.e. simultaneously by 2 or more threads.
In other words, you got yourself a race condition as nothing seems to protect that critical path of your code. Moreover, I would expect the Swift compiler to tell you that -- in theory it should already warn you that the access to initialFetch is unsafe.

What you may want to do is make Feed declared on the @MainActor entirely, rather than only a subset of its methods.

I think you get the question! the goal is to make the accessing and setting of initialFetch thread safe and not a race condition. I want to make sure that the task that finishes first does the setting of initialFetch.

So my making the entire class MainActor everything will be ran on the main thread. This is different than just having the function that the task calls set to MainActor? Since the tasks are on unknown threads, accessing data from the class, setting the entire class to MainActor would still cause those tasks to be on unknown threads except to access the initialFetch property it would happen on the main thread?

Sorry if that doesn't make sense I can try to clarify. I really appreciate the help.