This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 60774
    
  65

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 ?
 
Similar Threads
Using the Strategy Pattern in Struts Actions
Thread safety in Servlets
Thread-safety
Multi thread servlets and the Server applications they call.
When to use Instance vs Local variables