It is helpful to keep the thread from interfering with one another while sharing the information. It can be done in 3 ways:
Lock or monitor is known for built around an internal entity in synchronization. The thread requires consistent access to the object fields that acquire the object lock before accessing the lock.
Java.util.concurrent.locks has several lock implementation methods.
Deadlock is part of multithreading. It can occur in the condition when the thread is waiting for object lock that acquired by another thread & 2nd thread waiting for object lock that acquired for 1st thread. When both of the threads are in waiting for each other to release the lock the situation is known as deadlock.