What Is Synchronization In Java?

4

4 Answers

Anonymous Profile
Anonymous answered
Synchronization is used to prevent to occur the dead lock condition.if one or more threads has process at the same time but the synchronization key has in only one thread that thread will complete the process and then release the key the another thread has kept the released key and then process has go continues the synchronization used to prevent the interrupt the one thread to another thread.
Javin Paul Profile
Javin Paul answered
In my opinion Synchronization is used to protect shared resource in multi-threading environment in concurrent programming. Now days concurrency is must have feature because of multiple core cpu and to leverage your hardware fully you need to program your application to run concurrently and without correct synchronization you can't do that. Incorrect synchronization can result to various issues which is hard to find and debug as race conditions, deadlock, live lock , memory inconsistency etc. In Java synchronization is supported mainly with the use of synchronized keyword but there are others also e.g. Atomic classes, volatile keyword and concurrency package. To understand the concept you need to understand visibility, ordering and consistency part which is key to successfully write concurrent application. You can check below like to find more about synchronization in Java.
Venakata SivaKrishna Profile
The synchronized key word is used to avoid deadlock condition. If two threads are trying to access the same method, only one thread is allowed into the method. The second thread has to wait until the first thread completes the execution of the Synchronized method.

Answer Question

Anonymous