Jumat, 27 Januari 2017

Why do we need synchronization in Java Programming

When two or more threads are accessing the same resource like a variable or a data structure, it may lead to inconsistent data or values. Such conditions that lead to inconsistency are known as race conditions.   As an example let’s consider a variable count whose value is 7 at present. Consider two operations: count = count + 1 which is executed by thread1 and another operation count = count – 1 which is executed by thread2. Note that both threads are sharing the common variable count.   If both threads execute in parallel then the sequence of operations can be either: count = count +

The post Why do we need synchronization in Java Programming appeared first on Coding Security.


Why do we need synchronization in Java Programming
read more

Tidak ada komentar:

Posting Komentar