Future Methods in Salesforce
Future annotation is used to identify methods that are executed asynchronously. When you specify future, the method executes when Salesforce has available resources.
For example, you can use the future annotation when making an asynchronous Web service callout to an external service. Without the annotation, the Web service callout is made from the same thread that is executing the Apex code, and no additional processing can occur until the callout is complete (synchronous processing).
Email Class
Points to Remember about future method :
- No more than 10 method calls per Apex invocation.
- The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types.
- Methods with the future annotation cannot take sObjects or objects as arguments.
- Methods with the future annotation cannot be used in Visualforce controllers in either getMethodName or setMethodName methods, nor in the constructor.
- You cannot call a method annotated with future from a method that also has the future annotation. Nor can you call a trigger from an annotated method that calls another annotated method.
- @future(callout = true) means that the method has ability to invoke external web services.