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??



For an example, if we have some variable in run method, and we created one or more threads. Does a..

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

Post New Answer

More Advanced Java Interview Questions

difference between applicationserver and webserver

2 Answers   SolutionNET,


What exceptions are thrown by RMI?

1 Answers  


What are the different algorithms used for clustering?

0 Answers  


What is the purpose of the notify() method?

0 Answers  


What is Bootstrapping in RMI?

1 Answers  






Which Taglibraury you used in your project? plz send me ans....which we r using generally

2 Answers  


Difference Between getRequest and PostRequest?

8 Answers   HCL, TCS,


What is serialization and de-serialization ?

5 Answers  


difference between  ejb,struts,hibernate,spring and jsp

0 Answers  


what are the advantages of JTA over JTS?

0 Answers  


Do we need to override service() method

0 Answers  


Why do I get a duplicate name error when loading a jar file?

0 Answers  


Categories