O'Reilly logo

Apex Design Patterns by Anshul Verma, Jitendra Zaa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The active object pattern

To overcome the preceding race condition in concurrency, we can use the active object pattern.

Note

The active object pattern decouples the method execution from its invocation. Mostly, the active object pattern executes in asynchronous mode. Requesters submit a task as an object in a queue, and a scheduler picks an object from the queue and executes its logic. An object in the queue knows what to do when invoked, and that's the reason why the name of the pattern is active object.

As Apex does not support multithreading, we cannot create a shareable queue, which can be accessed by multiple threads simultaneously; and therefore, we will do it with the help of the  Pending_Request__c custom object. This custom object will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required