3. Consider the following
servlet code:
public class TestServlet extends HttpServlet
implements SingleThreadModel
{
private static Hashtable staticHash = new StringBuffer();
private Hashtable instanceHash = new StringBuffer();
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
StringBuffer sb = new StringBuffer()
HttpSession session = request.getSession();
servletContext ctx =getServletContext();
// 1
}
}
Which of the following lines can be inserted at //1 so that the StringBuffer
object referred to by the variable sb can only be accessed from a single
thread at
a time? (Select two)
a staticHash.put("sb", sb);
b instanceHash.put("sb", sb);
c session.setAttribute("sb", sb);
d ctx.setAttribute("sb", sb);
e req.setAttribute("sb", sb);
which two?
I select a,b and e