I was wondering if a function in a script can be called (from another script) while the Update() in that script is running?
I want to know this because, my Update function modifies an array, that the function X also would like to modify, and I would like them to modify it one at a time. Currently I'm setting a boolean to true in the beginning of update, and to false in the end, in order to see if it is running.
I was just wondering if that is completely unnecessary, since unity is not multithreaded.
Unless you explicitly use multi-threading (invoking threads, etc.) scripting in Unity is single-threaded. All callbacks, and even coroutines are executed serially.
In your example, Script.X() will never be called during Script.Update() unless Update() invokes the function at some level. You can safely remove the lock and your scripts should still work together.