Use of global variables in a forEach within a BPEL process
In a business process, a forEach activity is very useful in cases where you want to interact with a set of partners in parallel, and the partners are dynamically determined at runtime. When using forEach in its parallel mode, be very careful when changing variables that are global (created outside the scope of the forEach). There is no semantics of what order parallel branches get executed in. What this means in reality is that when the parallel branches of the forEach execute, if they are assigned to global variables, there is no definition of which order those assignments will get executed in.
With scope isolation, WS-BPEL 2.0 allows you to control the access of global data. If a scope's isolated attribute is set to 'yes', then it is guaranteed that there will be no concurrent access to the global data that the scope is referencing while the scope executes. For a very informative article on the usage of the forEach activity, available attributes, and typical usage patterns with code snippets, please refer to the following article:
http://www-01.ibm.com/support/docview.wss?rs=2307&context=SSQH9M&uid=swg27011753