Minggu, 26 Maret 2017

Why do we need Synchronization between Threads

Why Synchronization is Needed? When two or more threads are accessing the same resource like a variables or a data structures, it may lead to inconsistent data or value. Such condition that lead to inconsistency are known as race condition.   As an example let’s consider a variable counts 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 variables count.   If both threads execute in parallel then the sequence of operation can be either:

The post Why do we need Synchronization between Threads appeared first on Coding Security.


Why do we need Synchronization between Threads
read more

Tidak ada komentar:

Posting Komentar