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
what is the use of State Factories?
What is the difference between session and entity beans?
Which characters may be used as the second character of an identifier, but not as the first character of an identifier?
Java is fully object oriented languages or not?
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
Is a class a subclass of itself?
Should synchronization primitives be used on bean methods?
Describe activation process?
What is ripple effect?
What is the relation between the infobus and rmi?
What is the difference between the ‘font’ and ‘fontmetrics’ class?
What are the pros and cons of detached objects?
whats is mean by tiles in struts
what is Activation Instantinator?
What restrictions are placed on the values of each case of a switch statement?