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 processes to run in parallel) |
| Governor Limits | Standard governor limits apply | Higher limits for certain operations, like callouts and processing time |
| Use Case | Quick operations that need immediate results, like record validation | Large data processing, complex operations, and tasks that don’t need immediate feedback |
| Timeout limit | Shorter ( 10 seconds) | Longer (up to 60 seconds) |
| Example | CRUD operations, simple validation checks | Batch Apex, Future methods, Queueable Apex, Scheduled jobs |
Types of Asynchronous Process in Salesforce Apex
The different types of asynchronous processes in Salesforce Apex are mentioned below.
1. Future Methods – This is the basic Asynchronous apex in Salesforce that prevents any transaction delay during a web callout.
2. Batch Apex – When there is a requirement to process multiple records for the job together, a larger query result is required; in that case, we use the asynchronous batch in Salesforce Apex.
3. Queable Apex – It is an asynchronous processing framework that allows complex background tasks to be executed. It enables chaining of jobs, supports complex data types, and provides better debugging options than @future methods. It is ideal for long-running or complex tasks that must be processed sequentially.
4. Scheduled Apex—This method allows us to schedule Apex code to run at specified times, automating recurring tasks such as data updates or integrations. To create a scheduled job, we write a class that implements the Schedulable interface and defines the execute method with the code to be run. We can then use the System.schedule method or Salesforce UI to set the job’s timing and frequency.
Future Methods in Salesforce Asynchronous Apex
In the Salesforce Asynchronous callout, let us discuss batch Apex and frequently used future methods. Any method using the @future annotation requires special consideration because it does not necessarily execute in the same order it is called.
What is Future Method in Salesforce?
In Salesforce, the Future method is one such method that runs asynchronously. This method executes long-running operations, such as callouts to external web services or any operation that runs in its own thread on its own time. These methods run in a separate thread after the main transaction completes, allowing the main process to proceed without waiting.
Future methods are helpful for offloading tasks that don’t need immediate completion, improving performance by reducing user wait times.
Future Method Syntax
To define a future method, annotate it with the @future annotation as follows.
global class MyClass {
@future
public static void myFutureMethod(){
// Operation logic
}
}Use of Future Method in Salesforce
There are many cases where we can use future methods in Salesforce.
- Prevent CPU Time Limit Exceedance: The @future method in Salesforce can effectively avoid hitting the CPU time limit and prevent lengthy logs.
- Trigger Callouts: While direct callouts from triggers are not allowed, encapsulating the callout logic within an @future method enables the execution of external web service calls within a trigger.
- Avoid Mixed DML Errors: A Mixed DML operation error occurs when there’s an attempt to modify both setup objects (like User or Profile) and non-setup objects (like Account or Contact) in the same transaction. To avoid this, these operations should be separated into different transactions.
- Increased Governor Limits: One advantage of using @future methods is that they offer higher limits on certain governor limits, such as SOQL query counts, allowing for better processing without hitting governor limits.
Use case example of Future method
Let’s take an example to understand the @future method in Salesforce Apex. There is a Contact object, and every time a new contact is added, we want to send a welcome email. Sending emails can be time-consuming, so we’ll use a future method to handle it asynchronously.
Now, we will create an Apex class using the @future annotation that will send an email to the contact.
public class ContactHelper {
// Future method to send email
@future
public static void sendWelcomeEmail(String contactEmail) {
// email sending process
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setToAddresses(new String[] { contactEmail });
email.setSubject('Welcome to Our Service');
email.setPlainTextBody('Thank you for joining us!');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
}
}
Create a trigger to call the method of sending email.
trigger ContactTrigger on Contact (after insert) {
for (Contact c : Trigger.new) {
ContactHelper.sendWelcomeEmail(c.Email);
}
}After creating and saving the apex class and the trigger, we will create a contact record to check if the method works correctly.
As we create the new contact record, the email should be sent to the contact’s email according to the trigger conditions.
For the test purpose, here I have entered my email account to see the mail and test the trigger.
Now, you can see in the image below that the email was successfully sent to the new contact’s email address.

This way, we can use the future method in Salesforce Classes and directly call a trigger.
Conclusion
In Salesforce Apex, asynchronous methods execute the process in the back end or in a different thread to save the CPU time limit in Salesforce. We have a different way to execute code in async, which is called Asynchronous Apex.
In this Salesforce tutorial, we have learned about the asynchronous methods along with their use cases, and with the help of an example, we understood how to use asynchronous future methods for trigger callout.
You may also like to read.
- Dependency Injection in Salesforce Apex Class
- Access Modifiers in Salesforce Apex Classes
- Salesforce Object Query Language (SOQL) in Apex
- Different Types of Exceptions in Salesforce Apex
- Queueable Apex Chaining in Salesforce With Examples

Abhijeet is a skilled Salesforce developer with experience in developing and integrating dashboards, data reports, and Salesforce applications. He is also skilled at optimizing processes and flow automation processes, coding, and executing complex project architecture. Read more about us | LinkedIn Profile.