You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Randy Layman <ra...@aswethink.com> on 2001/06/14 16:56:06 UTC

RE: MultiThreadModel-Problem?


> -----Original Message-----
> From: Sebastian Schulz [mailto:sebastian.schulz@sebastian-schulz.com]
> Sent: Thursday, June 14, 2001 11:09 AM
> To: tomcat-user@jakarta.apache.org
> Subject: MultiThreadModel-Problem?
> 
> 
> hi,
> 
> i use a servlet in MultiThreadModel-mode (default).
> when 2 users at the same time makes the same request
> to the servlet (a operation that needs a bit) it seams, that
> only the request of the user who was perhaps a millisecond
> earlier is responded correct, the other seams to be ignored.
> 
> (i think, this is perhaps a concurency-problem, but i do not use
> static variables and could not find an error)
I would check on access to synchronized objects/methods and resource access
(sockets, files, etc) to make sure that one isn't being blocked by the
other.

> 
> the second question is:  data-container like HashMap or HashSet
> are considered to be not Thread-save. Can i use such containers
> in a MultiThreadModel-Servlet or must i use only slower structures
> like Vector?
It depends upon how you use them - if you use a single structure for each
request (i.e. you have one Map that is passed between methods and not shared
with other threads) then you are fine.  If you need to use them from
multiple requests, then you need to use a synchronized structure if you want
to avoid strange bugs later.  There are methods on the java.util.Collections
class to make particular types of collections synchronized.  I don't know if
these are faster then their cousins (Vector, Hashtable, etc), but you might
want to check them out.

 
> 
> your help is realy needed, many thanks
> in advance!
> 
> basti
> 

	Randy