I’m thinking of this lock:
It will conditionally synchronize on the script engine instance itself, if the instance implements Lock. That means that effectively all execution with this engine is serialized (assuming that a similar mechanism is implemented everywhere in Core where a script is launched - I haven’t checked that), and it seems this applies to the Python engine as well as JavaScript:
So, the initialization lock isn’t strictly relevant to this, because it doesn’t enforce that only one script can run at the script engine at the time, but this locking mechanism does. This means that there’s no need for synchronization/locks to prevent concurrent access between invocations of the same script engine. It’s not fully watertight though, because you can still access objects from Core that might need synchronization/locks, and there’s still no way to do this (or maybe there is a way to invoke Java synchronization objects via JSR223 - I wouldn’t know).
But, for the most part, I think this will work without too many issues, the Core APIs mostly make defensive copies before handing out mutable objects.