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 are the diff types of exception?

1011


What are callback interfaces?

1058


Describe, in general, how java's garbage collector works?

994


What are the steps to write p-to-p model application?

2439


What’s jboss jbpm?

975


What is the relationship between local interfaces and container-managed relationships?

1080


What is an abstract method?

1010


What are local interfaces? Describe.

1167


What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

1024


Explain what is orm?

1071


Define aop(assepct oriented programing)?

1127


Which component handles cluster communication in jboss?

1072


AS a developer will u create a data source in connection pool? If so how will u do that, how to access the object from connection pool using IRAD tool?

2100


Can I run seam with jdk 1.4 and earlier?

946


What is the form of storage space in java?

2205