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 are the different approaches to represent an inheritance hierarchy?
What do you know about seam?
Name three component subclasses that support painting?
How primary key is implemented in Oracle?
What is in-memory replication?
Why do I get a duplicate name error when loading a jar file?
What is the infobus?
Why a component architecture for the java platform?
For which statements does it make sense to use a label?
What is a session? Can you share a session object between different theads?
int x=5,i=1,y=0; while(i<=5) { y=x++ + ++x; i=i+2; } System.out.println(x); System.out.println(y); System.out.println(i); How to solve this? Please explain!
What’s jboss jbpm?
What are callback interfaces?
What is the immediate superclass of the applet class?
Is the infobus client side only?