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 / 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 |
To make an object to begin executing as a separate thread, what method is used?
Can I have an action without a form?
What is servlet preinitialization
What class is the top of the awt event hierarchy?
What is Connection Pooling?
1 Answers Enteg Technologies, Infosys, Polaris,
What you mean by COM and DCOM?
Does Java pass arguments by value or reference?
the use of try and ffinally keyword
Why won’t the jvm terminate when I close all the application windows?
how convert java file to jar files?
what are getters and setters in Java with examples?
can i call multipule form beans in Action class?