• #20905
    Salesforce | Shubham Shubham #120
    Forcetalks

    Difference between synchronous and asynchronous in apex

    Asynchonous call vs Synchoronous Call

     

    #20910
    Salesforce | shariq shariq #1
    Forcetalks

    Synchronous Apex :-

    Synchronous term means existing or occurring at the same time. Synchronous Apex means entire Apex code is executed in one single go.

    Asynchronous Apex :-

    Asynchronous term means not existing or occurring at the same time. Asynchronous apex is executed when resources are available. So any calling method which calls Asynchronous apex wont wait for outcome of Asynchronous call. Calling method will go on further execution in code. And Asynchronous execution happens in separate thread and then it will return to main program.

    #20916
    Forcetalks

    Hello Shubham,

    An async call is queued up in Salesforce and run on a separate thread of execution. At this point it becomes decoupled from the calling action. That also means the calling action won’t block and wait for a response from the asycn call. Using the future annotation identifies methods that are executed asynchronously. They must also be static methods. There are some considerations to know when using async methods.

     

    you can learn more here: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_future.htm

    #20917
    #34138
    Salesforce | Parul Parul #2
    Forcetalks

    Synchronous:

    In a Synchronous call, the thread will wait until it completes its tasks before proceeding to next. In a Synchronous call, the code runs in single thread.

    Example:

    Trigger
    Controller Extension
    Custom Controller

    Asynchronous:

    In a Asynchronous call, the thread will not wait until it completes its tasks before proceeding to next. Instead it proceeds to next leaving it run in separate thread. In a Asynchronous call, the code runs in multiple threads which helps to do many tasks as background jobs.

    Example:

    Batch
    @future Annotation

     

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?