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 Posted / 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 |
Post New Answer View All Answers
What if the static modifier is removed from the signature of the main method?
Can I import same package/class twice? Will the jvm load the package twice at runtime?
Difference between swing and awt?
when A client sent a request to the server to open facebook page and close the browser after this request .at that time the same user do login by using a different browser then that session id will exist or not for the same client??
How to implement RMI in Java?
What is the difference between ear, jar and war file?
Are there books about seam?
What state does a thread enter when it terminates its processing?
When a thread blocks on i/o?
Why does the option tag render selected=selected instead of just selected?
What you mean by COM and DCOM?
If your ui seems to freeze periodically, what might be a likely reason?
Can I use multiple html form elements with the same name?
What is permgen or permanent generation?
Why is actionform a base class rather than an interface?