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 the difference between a static and a non-static inner class?
What are the benefits of detached objects?
What is DTD?
How are the elements of a cardlayout organized?
What is scalable, portability in the view of J2EE?
Why is string immutable in java?
What is meant by Superconductivity?
What is Bootstrapping in RMI?
What are the sequence of steps to write pub or sub model kind of application?
What modifiers may be used with an interface declaration?
What is a layout manager?
How many layers are there in RMI and what are they?