synchronized (cxt) {
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);
// This one is not needed, as cs is just a reference to
// the object that is stored in the context.
// You only need this if you want to replace an object in
// the context with a different object.
}
> -----Urspr�ngliche Nachricht-----
> Von: Vernon Wu [mailto:[EMAIL PROTECTED]]
> Gesendet: Donnerstag, 19. September 2002 23:27
> An: [EMAIL PROTECTED]
> Betreff: 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:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>