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
Define the remote object implementation?
What must a class do to implement an interface?
Explain the steps in details to load the server object dynamically?
Why a component architecture for the java platform?
How are the elements of a cardlayout organized?
To identify IDL language what mapping mechanism is used?
What is a tasks priority and how is it used in scheduling?
How will you pass parameters in RMI? Why do you serialize?
Name three subclasses of the component class?
Describe, in general, how java's garbage collector works?
difference between ejb,struts,hibernate,spring and jsp
What class is the top of the awt event hierarchy?
Is there a guarantee of uniqueness for entity beans?
What are the purpose of introspection?
Can I use multiple html form elements with the same name?