Re: AW: AW: How can I achieve thread safe for context attributes?

2002-09-23 Thread Vernon Wu

Ralph,

Thanks again for your information.

Before I posted this question, I was thinking about how to make the object thread 
safe, but not the other object that it is 
contained thread safe. The approach works. I just help it would drag the performance 
since the application can have a 
very large number of users.

Vernon

9/22/2002 11:24:09 PM, Ralph Einfeldt [EMAIL PROTECTED] wrote:

That depends on how much work is done inside the synchronized block
compared to the amount of work that is done outside this block.
The more is done inside the block the more the server will slow down
when concurrent requests hit blocks that are synchronized on the same 
object.

 -Ursprüngliche Nachricht-
 Von: Vernon Wu [mailto:[EMAIL PROTECTED]]
 Gesendet: Freitag, 20. September 2002 16:42
 An: Tomcat Users List
 Betreff: Re: AW: How can I achieve thread safe for context attributes?
 
 Thanks Ralph for the solutation. I, however, wonder whether 
 the server will be slow down a lot after the servlet context 
 is synchronized for the operation. The context is the center 
 object in the servlet.
  






--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




AW: AW: How can I achieve thread safe for context attributes?

2002-09-22 Thread Ralph Einfeldt

That depends on how much work is done inside the synchronized block
compared to the amount of work that is done outside this block.
The more is done inside the block the more the server will slow down
when concurrent requests hit blocks that are synchronized on the same 
object.

 -Ursprüngliche Nachricht-
 Von: Vernon Wu [mailto:[EMAIL PROTECTED]]
 Gesendet: Freitag, 20. September 2002 16:42
 An: Tomcat Users List
 Betreff: Re: AW: How can I achieve thread safe for context attributes?
 
 Thanks Ralph for the solutation. I, however, wonder whether 
 the server will be slow down a lot after the servlet context 
 is synchronized for the operation. The context is the center 
 object in the servlet.
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




AW: How can I achieve thread safe for context attributes?

2002-09-20 Thread Ralph Einfeldt


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]




Re: AW: How can I achieve thread safe for context attributes?

2002-09-20 Thread Vernon Wu


Thanks Ralph for the solutation. I, however, wonder whether the server will be slow 
down a lot after the servlet context 
is synchronized for the operation. The context is the center object in the servlet.
 
9/20/2002 12:17:09 AM, Ralph Einfeldt [EMAIL PROTECTED] wrote:


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]






--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




How can I achieve thread safe for context attributes?

2002-09-19 Thread Vernon Wu


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]