---
schema_version: "1"
id: 1564b684ab5019a3277c445043d8b4e8bee8604e5019c0675814a994df2c21a5
title: Asynchronous Apex
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_async_overview.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_async_overview.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c203dc2380267f18e628f7af23c3b3ce3c9092a83c69529fb1c864931063f478
description: Apex offers multiple ways for running your Apex code asynchronously. Choose the asynchronous Apex feature that best suits your needs.
---
# Asynchronous Apex

Apex offers multiple ways for running your Apex code asynchronously. Choose the asynchronous Apex feature that best suits your needs.

This table lists the asynchronous Apex features and when to use each.

<table class="featureTable sort_table" summary="">


        <thead class="thead sorted" align="left">
          <tr>
            <th class="featureTableHeader  " id="d131647e60">Asynchronous Apex Feature</th>

            <th class="featureTableHeader  " id="d131647e63">When to Use</th>

          </tr>

        </thead>

        <tbody class="tbody">
          <tr>
            <td class="entry" headers="d131647e60" data-title="Asynchronous Apex Feature"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_queueing_jobs.htm" title="Take control of your asynchronous Apex processes by using the Queueable interface. Salesforce recommends that you use Queueable Apex instead of Apex future methods. Queueables have the same use cases as future methods but offer extra benefits, including job IDs, support for non-primitive types, and job chaining.">Queueable Apex</a></td>

            <td class="entry" headers="d131647e63" data-title="When to Use">
              <ul class="ul bulletList">
                <li class="li">To start a long-running operation and get an ID for it</li>

                <li class="li">To pass complex types to a job</li>

                <li class="li">To chain jobs</li>

              </ul>

            </td>

          </tr>

          <tr>
            <td class="entry" headers="d131647e60" data-title="Asynchronous Apex Feature"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm" title="Use the Apex Scheduler to delay execution so that you can run Apex classes at a specified time. This is ideal for daily or weekly maintenance tasks using Batch Apex.">Scheduled Apex</a></td>

            <td class="entry" headers="d131647e63" data-title="When to Use">
              <ul class="ul bulletList">
                <li class="li">To schedule an Apex class to run on a specific schedule</li>

              </ul>

            </td>

          </tr>

          <tr>
            <td class="entry" headers="d131647e60" data-title="Asynchronous Apex Feature"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch.htm">Batch Apex</a></td>

            <td class="entry" headers="d131647e63" data-title="When to Use">
              <ul class="ul bulletList">
                <li class="li">For long-running jobs with large data volumes that need to be performed in batches, such
                  as database maintenance jobs</li>

                <li class="li">For jobs that need larger query results than regular transactions allow</li>

              </ul>

            </td>

          </tr>

          <tr>
            <td class="entry" headers="d131647e60" data-title="Asynchronous Apex Feature"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm" title="A future method runs asynchronously. You can call a future method to run long-running operations, such as callouts to external web services or any operation that you want to run in its own thread. You can also use future methods to isolate Data Manipulation Language (DML) operations on different sObject types to prevent the mixed DML error. Each future method is queued and runs when system resources become available. That way, the execution of your code doesn’t wait for the completion of a long-running operation. A benefit of future methods is that some governor limits are higher, such as SOQL query limits and heap size limits.">Future Methods</a></td>

            <td class="entry" headers="d131647e63" data-title="When to Use">
              <ul class="ul bulletList">
                <li class="li">When you have a long-running method and need to prevent delaying an Apex
                  transaction</li>

                <li class="li">When you make callouts to external Web services</li>

                <li class="li">To segregate DML operations and bypass the mixed save DML error</li>

              </ul>

            </td>

          </tr>

        </tbody>

      </table>

- **[Queueable Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_queueing_jobs.htm)**  
    Take control of your asynchronous Apex processes by using the Queueable interface. Salesforce recommends that you use Queueable Apex instead of Apex future methods. Queueables have the same use cases as future methods but offer extra benefits, including job IDs, support for non-primitive types, and job chaining.
- **[Apex Scheduler](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm)**  
    Use the Apex Scheduler to delay execution so that you can run Apex classes at a specified time. This is ideal for daily or weekly maintenance tasks using Batch Apex.
- **[Batch Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch.htm)**
- **[Future Methods](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm)**  
    A future method runs asynchronously. You can call a future method to run long-running operations, such as callouts to external web services or any operation that you want to run in its own thread. You can also use future methods to isolate Data Manipulation Language (DML) operations on different sObject types to prevent the mixed DML error. Each future method is queued and runs when system resources become available. That way, the execution of your code doesn’t wait for the completion of a long-running operation. A benefit of future methods is that some governor limits are higher, such as SOQL query limits and heap size limits.
- **[Large Data Processing with Cursors and Queueable Apex Versus Batch Apex](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_cursors_versus_batch.htm)**  
    Apex Cursors combined with chained Queueable Apex jobs are a powerful alternative to Batch Apex for processing large volumes of records. Cursors provide the record-traversal capabilities of Batch Apex, but offer greater flexibility in handling parallel jobs. With Batch Apex, only five active Batch Apex jobs are allowed at one time in your org. Jobs beyond this limit are placed in the Flex Queue, which is limited to 100 additional jobs. In orgs with high volumes of background processing, jobs can accumulate in the Flex Queue and delay critical work.

- [← Previous](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers.htm "Triggers")
- [Next →](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_web_services.htm "Exposing Apex Methods as SOAP Web Services")