Future

Apex code supports annotations that influence the way code runs. An annotation is preceded by the ’@’ sign and is added right before the method that is affected by the annotation.

One particularly significant annotation is future. When you use this annotation, the following method is executed asynchronously. Asynchronous execution means that the method executes when the Force Platform has available resources. Control is immediately returned to the module calling the future method.

Methods with the future annotation have to be declared as static and must not return a value. For instance, the following is a valid declaration:

@future
Static void futureMethod() {
 code_block;
 }

The future annotation is ideal for use with web service callouts ...

Get The Developer’s Guide to the Force.com Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.