Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What if the static modifier is removed from the signature of the main method?

1241


Can I import same package/class twice? Will the jvm load the package twice at runtime?

1153


Difference between swing and awt?

1299


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

1545


How to implement RMI in Java?

2874


What is the difference between ear, jar and war file?

1140


Are there books about seam?

1111


What state does a thread enter when it terminates its processing?

1065


When a thread blocks on i/o?

1102


Why does the option tag render selected=selected instead of just selected?

1178


What you mean by COM and DCOM?

1065


If your ui seems to freeze periodically, what might be a likely reason?

1043


Can I use multiple html form elements with the same name?

1058


What is permgen or permanent generation?

1028


Why is actionform a base class rather than an interface?

1066