Google News
logo
Salesforce - Interview Questions
What is Future annotation(@future)?
Future annotations are used to specify methods that are executed asynchronously.

Methods having future annotation must be static methods and can only return a void type. The arguments specified must be primitive data types or arrays of primitive data types or collections of primitive data types. These methods cannot take sObjects or objects as parameters.

When you specify a method with @future annotation, it will be executed only when Salesforce has available resources.

For example, you can use future annotation while making an asynchronous web service callout to an external service. Whereas without the usage of future annotation, web service callout will be created from the same thread which is executing the Apex code, and no additional processing will take place until that callout is complete (synchronous processing).

Syntax :
global class class_name
{
    @future
    Static void methodname(parameters)
    {
        //body of the method
    }
}
Advertisement