Multi-Threading : Local Variable ThreadSafety

Local Variable are thread safe by nature.Each thread  have its own execution context/stack which is used to store local variables.

When ever two threads are running both thread will have own stack and no thread never shares its stack. Local variables defined in method will be allocated in Stack. Once method execution is complete, stack frame will be removed .

 

 

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *