Since the introduction of the concept of multithreading in apex salesforce, there has been a drastic change in the way we code. Now multiple threads run in parallel, hence many tasks can be performed at the same time.
Salesforce too adhered to this concept taking a step forward in its endeavor and provided a multi-threaded environment.
But everything has its pros and cons and so did parallelism. Though it completely changed the way programs are executed but brought with it a new concurrency bug what we call as a race condition.
When does multithreading in apex salesforce actually occur?
Race condition occurs when two thread operates on the same object without proper synchronization and their operation interleaves on each other.Continue reading