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 race condition.
When does multithreading in apex salesforce actually occur?
Race condition occurs when two thread operate on same object without proper synchronization and there operation interleaves on each other. Continue reading