Simply the title is the question. If synchronized keyword available, any reference would be appreciated.
1 Answer
Apex is not a multi-threaded language, so there's no reason to have a concept of synchronized methods. While multiple threads of apex can be run at the same time they do not share context (static variables, object references, anything really).
-
2The only thing that could be synchronized is your data. And you can use FOR UPDATE keyword in your SOQL query to lock specific set of records. salesforce.com/us/developer/docs/apexcode/Content/… May 2, 2014 at 6:44
-
I actually had a pretty good use case where I could use a mutex around parallel batch jobs. salesforce.stackexchange.com/questions/370709/… Mar 5, 2022 at 20:21
-
Well, a mutex around org cache that each batch job reads/modifies in their
finish
method. Mar 7, 2022 at 22:29