commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject RE: [Logging] Thread safety guaruntee of Log classes?
Date Wed, 11 Dec 2002 23:01:57 GMT


On Wed, 11 Dec 2002, Jerome Jacobsen wrote:

> Date: Wed, 11 Dec 2002 17:49:24 -0500
> From: Jerome Jacobsen <jerome.jacobsen@gentootech.com>
> Reply-To: Jakarta Commons Users List <commons-user@jakarta.apache.org>,
>      jerome.jacobsen@gentootech.com
> To: Jakarta Commons Users List <commons-user@jakarta.apache.org>
> Subject: RE: [Logging] Thread safety guaruntee of Log classes?
>
> >
> > Declaring the Log variable static or not has zero effect on whether it is
> > threadsafe or not -- it only determines whether or not the Log instance is
> > shared across all instances of the declaring class.
> >
> > Craig
> >
>
> Huh?  Declaring the Log instance static means that it better be thread-safe.

True, but you're missing an important point.  Exactly the same is true for
a non-static declaration.

Consider a Struts Action class.  Struts creates a single instance of your
declared Action class, and it will be quite common to have multiple
requests processing through the action at the same time (and therefore
possibly triggering log calls at the same time).

It makes absolutely no difference whether or not the log variable itself
is declared statically.  It has to be thread safe either way.

Craig


Mime
View raw message