3 respostas
Hi,Batch Apex is stateless by default. That means for each execution of your execute method, you receive a fresh copy of your object. All fields of the class are initialized, static and instance. If your batch process needs information that is shared across transactions, one approach is to make the Batch Apex class itself stateful by implementing the Stateful interface. This instructs Force.com to preserve the values of your static and instance variables between transactions. It is used for not only taking count but also to use any information in the next batch and so on.
- Stateful (like WinForms): Stores the data for further use, but limits the scalability of an application, because it's limited by CPU or memory limits
- Stateless (Like ASP.NET - although ASP tries to be stateful with ViewStates): After actions are completed, the data gets transfered, and the instance gets handed back to the thread pool.
Please let me know if this helps.