function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to use 'synchronized' keyword in APEX.

I am making a webservice call and want to synchronize the block for making web service call. Here is the sample code:

         Http h = new Http();
         Httprequest req = new Httprequest();
         Httpresponse res = h.send(req);


Thnks & Regards,

Amrender Singh


What are you intending to do with a synchronized block? In today's platform, there is no way to specify a mutex, or run multiple threads in a single unit of execution, thus there is no way that the 'synchronized' keyword would possibly have any effect. Callouts to a web service are always synchronous; when the line HttpResponse res = h.send(req); completes, the HttpResponse object contains the full details of the callout, including a status, headers, and response payload.