Main thread issue?

Ok so, im having a little issue and i know that unity is not thread safe, but i dont see why this wont work. i am using this function :

public void destroyEntityInWorld(Entity entity)
    {
        Debug.Log("Destroying "+entity.entityName + " with ID value " + entity.entityID);
        GameObject reference = entities[entity.entityID];
        entities[entity.entityID] = null;
        gameManager.gameEngine.destroyGameObject(entity.entityName+"_"+entity.entityID);
        
    }

and i am getting a threading issue :

Find  can only be called from the main thread.

Does this mean that the other thread is trying to call the function on the other script? also is there a way to actually destroy a gameobject without mono? can i send a message to a function which is on the main thread to destroy it?

Also, the function i am calling is :

public void destroyGameObject(string name)
    {
        Destroy(GameObject.Find(name));
    }

Thanks.

The Unity API is more than not thread safe, it actually won’t allow you to even try to call any Unity function from any other thread than the main thread.

If you need to “call” a function from a thread that uses the Unity API you have to sync it with a function that actually runs in the main thread. This is a [usual threading problem] 1 and can be solved in different ways. Usually you implement a task-queue which has an access lock.

If you don’t understand threads and/or the problems they produce, you shouldn’t use them.

See this great page on Unity Gems about using threads in Unity