Thursday 7 July 2016

Difference between Synchronous and Asynchronous call in Salesforce





Hi Guys,

In almost 2nd interview this question is asked "What is the difference between Synchronous and Asynchronous call in terms of Salesforce?"

So here i tried to explain this in very simple words:-


Synchronous:

In simple terms you can assume Synchronous as Sequential. In Synchronous process the thread waits for the task to be completed and then moves to the next task Sequentially. All the tasks are completed in a single thread.
The common example of a Synchronous apex is Trigger.

Asynchronous:

In Asynchronous apex the thread does not waits for the task to be completed to move on to the next task. The tasks are run in different threads all together. These threads run in independent silos whenever the system is free.

Most common example is the Future annotation.

  

Thanks
Anurag Jain