function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Newbie__SalesforceNewbie__Salesforce 

Why queueable apex take member variables of non primitive type, what if when running the value of variables are changed ?

Your queueable class can contain member variables of non-primitive data types, such as sObjects or custom Apex types  then while executing in asyn process the value of the variables are changed will it work on old value or new value??

Thanks in advance!
 
HARSHIL U PARIKHHARSHIL U PARIKH
I would say you still want to avoid passing a SObject as a parameters even in queueable apex even though they are allowed.

The difference between Future and Queueable is that
1) in Future you cannot track the batch Id and in queueable you can.
2) You can chain multiple Future method in queueable interface class. This is very interesting though.. How? If you have multiple FUTURE method running then there is no way for us to control the execution of Future method but however, if you are in queueable apex then you can control the execution of jobs.

Below link also explains with an examples,

Link: https://developer.salesforce.com/forums/?id=906F0000000kK6VIAU


Hope this helps!