aspose file tools*
The moose likes Servlets and the fly likes Safe to use ArrayList without concerning thread ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Safe to use ArrayList without concerning thread ?" Watch "Safe to use ArrayList without concerning thread ?" New topic
Author

Safe to use ArrayList without concerning thread ?

Steve Mutanson
Ranch Hand

Joined: Apr 15, 2003
Posts: 67
We all know ArrayLIst is faster than Vector but it is not synchronized. In my servlet application, I have a central servlet which dispatches work to different action classes by passing the HttpeServletRequest and HttpServletResponse to them. Since I do not have any instance variable in the servlet class (I initiate action classes in doGet() method so the action class instance is thread safe), can I assume my application is thread safe and thus I can use ArrayList in my action classes without worrying about thread issue ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61653
    
  67

If each thread gets its own instance of an action class, then there should be no thread-safety issues.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Safe to use ArrayList without concerning thread ?