In the user guide, there is the note that the class must not use any member variables for Thread-safe of the service task.
However, if I need to have some input variables defined in a process definition, I must declare member variables such as “private Expression xxx” in the class.
Thus, it means I should not define any input variables for Java Service Task? Or is there the other around way to use any input variables with the thread-safe of the class?
Using member variables like "Expression expr" is perfect. When you want to get the value of this expression, it will be thread safe. But the Expression script itself is only injected once. So when you do this for a String member variable. the String value is only injected once and it'll not be thread safe. So bottom line, if you use Expressions it's fine, no thread safety problems there.
To summarize, you should evaluate the Expression against the DelegateExecution passed in the execute method, this will give you the input values of the service-task…