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
penchala rajupenchala raju 

what is synchronous & asynchronous operation in future method

All actions inside the future method are "synchronous."  The method is fired asynchronously from the rest of the code.  For example:

  • Trigger on Case that inserts CaseComment
  • Trigger on CaseComment that calls a @future method "UpdateCaseMilestones"
After transaction 1 completes, transaction 2 starts

  • UpdateCaseMilestones method start
  • Updates Case with data from CaseMilestone
All of the information in Transaction 1 and 2 are synchronous to their respective transactions.  However transaction 2 is asynchronous to transaction1.
rajesh gandirajesh gandi

Synchronous: everything is done in a single transaction

Asynchronous: everything is done in multiple transactions! 

One transaction is beneficial if you need to get certain information back from your method - for example, if you need to get an error/success message.  Also, since it's done on the same transaction, you get your results right away.

Multiple transactions are beneficial if you don't care if it works or not, you just want to save resources.

@Future Annotation:
Use the future annotation to identify methods that are executed asynchronously. When you specify future, the method executes when Salesforce has available resources.

@Future (callout = true)
Specify the method to make the callout to external systems. (e.g. To execute callout method via an Apex trigger)

Further details:

U got answer please select best answer