When a thread is already active on an object, Preventing any other thread from an action on the same object is called “Thread Synchronization” or “Thread safe”. Synchronization there are two way
2) Synchronization block:
Syntex: Synchronization(object) { Statement }
3) Synchronization keyword :
Syntex: Synchronization void displat() { Statement }
With respect to multithreading, synchronization is the capability to control the access of multiple threads to Shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object’s value. This often leads to significant errors.
Question and answer is powered by AnsPress.io