struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fzli...@omnytex.com
Subject Re: general Thread disscussion
Date Tue, 01 Feb 2005 19:09:10 GMT
On Tue, February 1, 2005 2:01 pm, listed@gmx.net said:
> Thank you for your detailed reply. Its really helpfull but i had two
> questions:

I try :)
 
>>... and it may even be forbidden by J2EE, but... doing it is OK if you
>> are careful a
> 
> I had a look in the J2EE-Specification but i can't found the point where
> this Topic is handled. Do you know where?

To be honest, I've only heard this in the past few days.  I didn't know that, generically,
writing files was "forbidden" by J2EE.  I knew it was something you generally want to avoid
from a webapp for other reasons, but it's news to me too :)  So no, I don't have any reference
I can point you to.  I'd be interested in such a reference myself!
 
>>Also, you NEVER want to hold references to any request-oriented resources
>> (in fact, your thread shouldn't even USE them, shouldn't even be aware
>> that it's running in a servlet container, if possible).
>
> Does this include ressources with synchronized-operations?
> For example a static HashMap with some Data.
> Some Client read of this HashMap (without synchronized) and the thread
> wrote with the synchronized-Expression in the HashMap

Just want to be sure I follow... Do you mean a case where you have a class along these lines:

public class myData {
  public static HashMap data = new HashMap();
}

... and you might be reading and/or writing from this during the course of processing a reqeust
AS WELL AS from a background thread?  If that's the question, the answer is you need to be
very careful.  You can synchronize all access to the HashMap, but then you are introducing
a bottleneck into the system at best, and a potential deadlock or any one of the other multitude
of thread contention issues that confuse the hell out of most of us when they crop up!

If your static information is read-only, you have no issue of course.  I do this in that application
I was talking about... I have a class almost identical to what you see above except that the
HashMap is private and I have a getter/setter pair.  It's never altered during the run of
the application though, after startup anyway, so no problem.  If it could be altered though,
that would change matters.
 
> Greets Felix

Hope that helps!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


Mime
View raw message