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 are the diff types of exception?
What are callback interfaces?
Describe, in general, how java's garbage collector works?
What are the steps to write p-to-p model application?
What’s jboss jbpm?
What is the relationship between local interfaces and container-managed relationships?
What is an abstract method?
What are local interfaces? Describe.
What is re-entrant. Is session beans reentrant. Is entity beans reentrant?
Explain what is orm?
Define aop(assepct oriented programing)?
Which component handles cluster communication in jboss?
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?
Can I run seam with jdk 1.4 and earlier?
What is the form of storage space in java?