I'm developing an application where Jython scripts would be executed once in a while as part of executing a workflow of tasks. So the number of tasks and the time when they execute can be random and depends on the users' input. In any case it can happen in parallel.
The question is, should I better create a separate new engine for each scripts, like in "new ScriptEngineManager().getEngineByName(PYTHON_ENGINE)". Or should I instead create the engine once globally for my application and then just call "jythonEngine.eval(script, scriptContext)" whenever running a user's task?
Maybe creating a new engine for each execution would be much slower? Or maybe reusing the engine could lead to some isolation problems?