Rog�rio Meneguelli Gatto wrote:

> Hello guys,
>
> We developed a log class (all static methods), that can handle multiple log files, 
>etc.  This class is being used for custom logging on all our servlets.
>
> It takes its parameters from a config file, and detects updates to its 
>configuration.  So, if config info changes, this class issues a synchronized 
>"reset()", to close files, etc.
>
> Consider this situation:
>
> 1. there is already a Thread A running a (static) method of my class;
> 2. config changes, and (synchronized static) reset() is called from Thread B;
>
> Will A be interrupted, while B reset()s, and then continue OR will B wait for A to 
>finish its operation?
>

A will never be interrupted by B calling a synchronized static method.

B will wait for A to finish before it starts if A is executing a synchronized static 
method; otherwise, it will proceed in parallel.

Synchronizing a static method is pretty much the same as synchronizing on the Class 
object of the underlying class.  The basic rule to remember is that synchronization 
locks only help
you if all code paths needing protection from each other are synchronized on the same 
object.

Is auto-detecting configuration file changes on something like this really worth the 
runtime overhead it costs you?  Synchronized method calls are slower than 
non-synchronized ones,
although this is less an issue in 1.2 and especially Hotspot JVMs than in 1.1.

> TIA
> Rog�rio Gatto
>

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to