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



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

What is the difference between a static and a non-static inner class?

0 Answers  


What are the benefits of detached objects?

0 Answers  


What is DTD?

3 Answers   Wipro,


How are the elements of a cardlayout organized?

0 Answers  


What is scalable, portability in the view of J2EE?

0 Answers  


Why is string immutable in java?

0 Answers  


What is meant by Superconductivity?

4 Answers  


What is Bootstrapping in RMI?

1 Answers  


What are the sequence of steps to write pub or sub model kind of application?

0 Answers   TCS,


What modifiers may be used with an interface declaration?

0 Answers  


What is a layout manager?

2 Answers  


How many layers are there in RMI and what are they?

1 Answers  


Categories