In Salesforce Apex, Asynchronous refers to executing code outside the normal processing flow of a Salesforce transaction. Instead of running immediately, asynchronous processes are scheduled to execute later.
Asynchronous Apex is helpful for handling the governor limits when there are limited resources available in a multi-tenant architecture; it is hard to decide how to utilize resources to their maximum limit. In this situation, we use asynchronous Apex to maximize resource utilization.
What is Asynchronous Apex in Salesforce?
The term Asynchronous refers to a method that runs independently without depending on other processes. In Salesforce, we can understand an asynchronous Apex as a thread or process that does not wait until it completes its tasks before proceeding to the next. Instead, it leaves it next, running in a separate thread.
This method of running code in multiple threads allows us to do many tasks, as background jobs offer multiple ways for running Apex code asynchronously.
Synchronous vs Asynchronous in Salesforce Apex
| Aspect | Synchronous Apex | Asynchronous Apex |
| Execution Timing | Runs Immediately | Runs in the background (doesn’t wait for immediate completion) |
| Threading | Single-threaded (one operation completes before the next begins) | Multi-threaded (allows multiple proc |