Example & Tutorial understanding programming in easy ways.

Why synchronization is important?

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 causes dirty data and leads to significant errors. The disadvantage of synchronization is that it can cause deadlocks when two threads are waiting on each other to do something.

Also synchronized code has the overhead of acquiring lock, which can adversely affect the performance.

Read More →