While we work with multithreading, we should follow best practices to write a smooth code. A smooth code is where a developer doesn't face deadlock. In other words, multithreading requires a lot of care during the writing process.
While multiple threads are running in a class/program, deadlock occurs when each thread approaches the object or resource written under a lock statement. The actual deadlock occurs when each thread approaches to lock an object/resource that is already locked by another thread.
A small mistake can result in developers having to tackle unknown bugs that occur due to threads that are blocked. In addition to this, a bad implementation of a few words in the code can impact 100 lines of code.
Let's go back to our example of conference tickets, which we discussed at the beginning of this chapter...