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

2042


How substring() method of string class create memory leaks?

787


Difference between hashmap and hashtable?

852


What are the diff types of exception?

775


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

2030


What are externizable interface?

803


What is abstract schema?

780


Can I run seam outside of jboss as?

839


Explain about thread synchronization inside a monitor?

2247


What do you mean by Socket Programming?

792


What is the difference between system.out ,system.err and system.in?

835


What is ioc concept & explain it?

841


Can you give me a simple example of using the requiredif validator rule?

871


What is permgen or permanent generation?

791


Define aop(assepct oriented programing)?

915