Very interesting, thank you Jeff. I am using an instance of the date format class as a private member variable in one of my buisiness objects. Each client request has one of these business objects created and placed into the session for use, as mentioned previously I too use a new getter method to provide formated dates to my jsp's. I believe this use is thread safe in that I am not creating any new threads in my app.
Some developers have mentioned that the DateFormat objects are heavy weight(too heavy for each client session?). Should the date format object only have local scope in a method or be a globaly syncronized object for all to use? -----Original Message----- From: Jeff Martin [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 05, 2002 12:26 PM To: Struts Users Mailing List Subject: RE: Thread Safety Question (was Formatting Dates, Integers...) Any use of java.text.DateFormat (or its subclasses) format method is thread unsafe (quite to my surprise). The problem comes from DateFormat holding an instance of a Calendar to help it break the java.util.Date into pieces. When a second thread calls format() while another thread is still in format(), it naturally starts poking the new month/day/etc into the [same!] calendar, overwriting what the first thread put there [and is still using]. It goes downhill from there. I got anything from garbled/mixed dates to NullPointerExceptions, depending on when and where the two threads were. Jeff -----Original Message----- From: Keith Bacon [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 05, 2002 5:12 AM To: Struts Users Mailing List Subject: Thread Safety Question (was Formatting Dates, Integers...) Do you know what the problem was that made your use of format objects non-thread safe? > -----Original Message----- > From: Jeff Martin [mailto:[EMAIL PROTECTED]] > Sent: Monday, February 04, 2002 5:56 PM > To: Struts Users Mailing List > Subject: RE: Formatting Dates, Integers... > > > Be very careful about using DateFormatter's that way. I learned a hard > lesson in a previous project that DateFormater (and even just the format > method) is not thread safe. > > Jeff > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

