• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Safe to use ArrayList without concerning thread ?

 
Steve Mutanson
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If each thread gets its own instance of an action class, then there should be no thread-safety issues.
hth,
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic