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 is the use of State Factories?

2328


What is the difference between session and entity beans?

1051


Which characters may be used as the second character of an identifier, but not as the first character of an identifier?

998


Java is fully object oriented languages or not?

945


A user of a web application sees a jsessionid argument in the URL whenever a resource is accessed. What does this mean? a. The form must have the field jsessionid b. URL rewriting is used as the session method c. Cookies are used for managing sessions

2191


Is a class a subclass of itself?

1131


Should synchronization primitives be used on bean methods?

1004


Describe activation process?

2603


What is ripple effect?

1027


What is the relation between the infobus and rmi?

953


What is the difference between the ‘font’ and ‘fontmetrics’ class?

1109


What are the pros and cons of detached objects?

932


whats is mean by tiles in struts

2143


what is Activation Instantinator?

2371


What restrictions are placed on the values of each case of a switch statement?

957