Multi Threading programming
what Regular problem face during Multi Threading programming?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Feb 10, 2015, 8:11 AM
To avoid the chaos which might otherwise ensue, some method needs to be used to control the order in which the threads access such variables. The commonest method is to use 'locks' i.e. a thread is not allowed to enter code where such variables are accessed until the thread which currently owns the lock has released it. This ensures that only one thread at a time can enter critical sections of code and the others therefore need to be queued until it is their turn to enter it.
The problem can also be avoided altogether by using immutable state i.e. objects which once created can't be changed.