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

Difference between Queueable apex and future method

I understand that you could pass collection of Sobjects to Queueable apex classes but not to future methods where we're restricted to only primitive collections. The reason it's not done for future methods is that the objects could potentially change from the time it's passed to the time when the future method executes.

Question - Will this hypothesis not hold true for Queueable apex and even batch apex for that matter (record value/criteria could change from when it's executed by the start method to when it's processed by the execute method when processing large sets of batches -- unless you completely take the sf org down for maitenance, in which case, this shouldn't be an issue for both queuable and batch apex) - Is that an expectation for both Queueable and Batch apex? or are there any alternatives?

Just wanted to get the group's thoughts on this one.
Jeff DouglasJeff Douglas
You can pass collection or sObjects to Queueable Apex but the underlying data may also change by the time the Apex executes. You typically don't have this problem with Batch Apex.

Jeff Douglas
Trailhead Developer Advocate
Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri
when dealing with large data, you can't make bathces using queuable apex