Friday, March 9, 2012

Threads fundamentals

1. What is meeaning of Concurrent access by multiple threads
Since only one thread is actively running at any point of time , so what' the meaning of concurrent access or simultaneous access ?

Ans :
Threads store method variable on a local stack.Global object reside on heap bu the reference to the global objects are again stored in the stack.
So when two or more threads have the same-state-stack ( that means stack having same values for the all the local and global variables ) at any given cpu snippet , then it can be said to be a concurrency probelm.

Local method variables are just OK, they dont affect or create a concurrent problem. It's the global references that are in a risk of having a inconsistent state.