The script declaration defines the execution mode for all instances of the script package as one of these choices:
Serialized: entry points for all script instances in the same execution group are never invoked concurrently.
Concurrent: entry points for the same or different script instances of the script may be executed concurrently.
Persistent: entry points are invoked in the same "private" thread (and thus are inherently serialized), and some information can be preserved between invocations.
In concurrent execution mode, the entry points for the same or different script instances of the script may be called concurrently. In other words, two or more script instances of the same type may run in parallel and even two or more entry points for a particular script instance may run in parallel (for example, the jobArrived and timerFired entry points).
For example, a flow containing a single flow element with a concurrent script (in addition to input/output folders) will pick up and process multiple input jobs at the same time – within the overall processing limits configured through user preferences.
Script implementations with concurrent execution mode must take care to synchronize access to resources that are shared between script instances or between different entry points. For example, access to a text file that is updated from both the jobArrived and timerFired entry points should be synchronized using the Environment.lock/unlockGlobalData() functions.
In serialized execution mode, entry points for script instances in the same execution group are never called concurrently. In other words, script instances in the same execution group are executed one after another. Still, the entry points in script instances outside of the execution group may be executing in parallel with those in the group.
Script implementations that need to be serialized between each other (perhaps because they use a common external resource) should refer to the same execution group. Usually however a script implementation needs serialization only with itself. In that case, the execution group name should be unique to the script implementation.
In persistent execution mode:
All entry points for all script instances in the same execution group are executed in the same thread (except for cleanupAfterAbort), and thus by definition execution is serialized (in serialized mode execution is serialized but consecutive invocations may happen in different threads).
The contents of the predefined global script variable "persistent" is preserved across all invocations of entry points, whether from the same script instance or not (this persistence is the reason why all invocations must happen in the same thread).
The entry points initializeProcessing, finalizeProcessing and cleanupAfterAbort are invoked at the appropriate times to help manage resources (such as an external application) that persist across invocations of jobArrived and timerFired entry points.
A new execution mode, called the multiple persistent allows the combination of concurrency and persistency.