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



For an example, if we have some variable in run method, and we created one or more threads. Does a..

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

Post New Answer

More Advanced Java Interview Questions

What is a compilation unit?

1 Answers  


what is the diffrence between banking and insurance domain?

2 Answers  


What is an abstract method?

0 Answers  


Explain phantom read?

0 Answers  


What are externizable interface?

0 Answers  


1) which method of the RequestDispatcher cannot be called once the output is sent to the client? a. forward b. include c. both a&b 2) which interface should an object implement to get notified of changes to the list of active sessions in a web application? a. HttpSessionListener b. HttpSessionActivationListener c. HttpSessionAttributeLIstener 3) A user can select multiple locations from a list box on an HTML form, which of the following methods can be used to retrieve all the selected location? a. getParameter() b. getParameterValues() c. getParamValues() 4) which of the following methods should be used to send character text to the client? a. ServletResponse.getWriter() b. ServletResponse.getOutputStream() c. ServletResponse.getOut() 5) which implicit object is always available in a JSP page? a. exception b. session c. out 6) which inclusion mechanism doesn't include the source of the page, rather the output of the page. a. include directive b. jsp:include action c. Bothe a& b 7) which attribute of the page controls whether a page participates in session or not? a. session-allowed b. session c. isSession

1 Answers  


What is the RMI and Socket?

0 Answers  


Can we define constructors in Servlet?

3 Answers   Accenture, Opus, Wipro,


Is it possible to stop the execution of a method before completion in a sessionbean?

0 Answers  


What is Remote Interface?

1 Answers  


What is the need of serialize?

2 Answers   Wipro,


If I define a method in JSP scriplet <%..%>, where will it go after translation into a servlet?

8 Answers   HeadStrong,


Categories