Paul Foxton wrote:

> Hi Bo, thanks for your reply
>
> I think I follow you, and you seem to be saying the same things as Hans,
>
> apart from this part:
>
> > no,  but please notice that  this local/method can not refrence to a
> > instance/static
> > field of MyServlet, or refrence to a object shared by several
> > Threads, for
> > example:
> > doGet(...){
> > ...
> > HttpSession session=req.getSession();
> > session.getAttibute(...)/setAttibute(...);
> > ...
> > }
> >
> > session is a local variable, but because it references to
> > req.getSession(), so
> > I think  "synchronized" need to be used here
> >
>
> - isn't the point of the getSession method is that a new instance of the
> Session object is created for each new request, so each new thread spawned
> by a request would have its own instance of Session?
>
> Hope I havn't misunderstood you.
>
> thanks,
>
> Paul
> [...]

Hello Paul,  I find it is not suitable to use HttpSession as the sample for
Thread/local-variable issue in my last email, it make the explaination more
complicated :-)   because I found(with TC4.0b5), for every req,
session.hashCode()
is different, even if session.getId() is same.

I still guess session.getAttibute(...)/setAttibute(...) need to be
"synchronized",
but perhaps I can not use session itself to do it, I think it is possible to
use a
context-wide object as "mutex".

so I think I need to use another sample:

doGet(...){
...
ServletContext context = getServletContext();
context.getAttibute(...)/setAttibute(...);
 ...
}
context is a local variable, but because it references to
getServletContext(), so perhaps  "synchronized" need to be
used here.


have a nice afternoon :-)

Bo
July 16, 2001

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to