For an example, if we have some variable in run method, and
we created one or more threads. Does all threads will share
the same variable or a copy of variable is created for each
thread??
Answer / ranganathkini
No, each thread will have its own copy of the variable.
The reason is that run() is a method and any variable
declared inside a method is considered a local method and
its scope remains only within that method. If new thread
instances are spawned then each thread instances' run()
method will have their own copy of the variable.
Is This Answer Correct ? | 3 Yes | 0 No |
What is Servlet Filter And What does it work?
How to implement dphibernate to activate lazy loading in Flex with java ?thanx in advance!
how java is os independent language ?
difference between ejb,struts,hibernate,spring and jsp
Is the ternary operator written x : y ? Z or x ? Y : z ?
What is waiting state? In what ways a thread can enter into waiting state?
How will the struts know which action class to call when you submit a form?
Is there a guarantee of uniqueness for entity beans?
What is the difference between the font and fontmetrics classes?
What is the difference between Super and This Keyword?
What is threadfactory?
whats is mean by class.forName() whats the return type of class