TLDR
There is a certain flow of the program that has to be reached in order for it to work without deadlocks and data loss. Deadlocks or race conditions can occur while you are accessing shared resources from multiple threads at the same time. When you run a program with multithreading it is very hard to debug what happens when exactly and which thread has priority over other threads to access the shared resource. This is where locks come into play and we use them to prevent those same deadlocks.via the TL;DR App
no story