You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vernon Wu <ve...@gatewaytech.com> on 2002/09/19 23:26:45 UTC

How can I achieve thread safe for context attributes?

I have an attribute stored in the servlet context scope. Various sessions can access it at any giving moment. It must be 
thread safe. How can achieve thread safe?

	CurrentUsers cs = (CurrentUsers)cxt.getAttribute(WebKeys.CurrentUsers);
	String user = (String)session.getAttribute(WebKeys.UserID);
      	cs.remove(user); // or other modification
      	cxt.setAttribute(WebKeys.CurrentUsers, cs);
 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>