I just looked at it and it is not threadsafe at all - it stores a lot of
state in instance vars. So calls should either be synchronized or you should
create a new instance each time (or keep one instance per thread, but it
would be PITA to maintain...)

--
fedor.

----
"I am, in point of fact, a particularly haughty and exclusive person,
of pre-Adamite ancestral descent.  You will understand this when I tell
you that I can trace my ancestry back to a protoplasmal primordial
atomic globule.  Consequently, my family pride is something
inconceivable.  I can't help it.  I was born sneering."
                -- Pooh-Bah, "The Mikado", Gilbert & Sullivan


> -----Original Message-----
> From: John McNally [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 15, 2002 1:55 PM
> To: Turbine Developers List
> Subject: Re: cvs commit:
> jakarta-turbine-torque/src/java/org/apache/torque/adapter DBMM.java
> 
> 
> Is there a specific implementation that is known to be 
> thread-unsafe?  I
> looked at sun's implementation some time ago and concluded that
> format(date) could be called by multiple threads safely.  Maybe I was
> wrong, but why would someone implement the format method to modify
> object properties?
> 
> john mcnally
> 
> [EMAIL PROTECTED] wrote:
> > 
> > dlr         02/03/15 13:29:37
> > 
> >   Modified:    src/java/org/apache/torque/adapter DBMM.java
> >   Log:
> >   SimpleDateFormat is not thread-safe -- corrected usage 
> problem turned
> >   up by conversation with Bill Schneider <[EMAIL PROTECTED]>.
> > 
> >   Revision  Changes    Path
> >   1.7       +3 -4      
> jakarta-turbine-torque/src/java/org/apache/torque/adapter/DBMM.java
> > 
> >   Index: DBMM.java
> >   
> ===================================================================
> >   RCS file: 
> /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/ad
> apter/DBMM.java,v
> >   retrieving revision 1.6
> >   retrieving revision 1.7
> >   diff -u -u -r1.6 -r1.7
> >   --- DBMM.java 22 Aug 2001 20:12:08 -0000      1.6
> >   +++ DBMM.java 15 Mar 2002 21:29:37 -0000      1.7
> >   @@ -73,13 +73,12 @@
> >     *
> >     * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
> >     * @author <a href="mailto:[EMAIL PROTECTED]";>Brett 
> McLaughlin</a>
> >   - * @version $Id: DBMM.java,v 1.6 2001/08/22 20:12:08 dlr Exp $
> >   + * @version $Id: DBMM.java,v 1.7 2002/03/15 21:29:37 dlr Exp $
> >     */
> >    public class DBMM
> >        extends DB
> >    {
> >   -    private static final SimpleDateFormat DATE_FORMATTER =
> >   -        new SimpleDateFormat("yyyyMMddHHmmss");
> >   +    private static final String DATE_FORMAT = "yyyyMMddHHmmss";
> > 
> >        /**
> >         * Empty constructor.
> >   @@ -216,6 +215,6 @@
> >         */
> >        public String getDateString(Date date)
> >        {
> >   -       return '\'' + DATE_FORMATTER.format(date) + '\'';
> >   +       return '\'' + new 
> SimpleDateFormat(DATE_FORMAT).format(date) + '\'';
> >        }
> >    }
> > 
> > 
> > 
> > 
> > --
> > 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]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to