Peter B. West wrote:
> Please indulge my ignorance again.  May I assume that it is not possible 
> to run two main()s in the same VM?

Not in the sense you probably mean.

>  From this discussion so far I have gained much more insight into the 
> nervousness about statics.  Is the problem that servers want to execute 
> multiple instances of classes within the one VM?  Are there other problems?

The problem is multiple threads accessing static class data,
which is really global.
Well, the standard scenario is: There are multiple threads
sleeping while waiting for requests. One thread wakes up,
sets the FOP baseDir, creates a Driver instqance and starts
rendering. Just before the thread is about to resolve an URI
for an external graphic, it is suspended and another thread
gets a chance to run, it reads its request, sets the global
baseDir to soemthing else, and is itself suspended in favour
for the first thread, which reads the now changed value for
baseDir from the configuration, and explodes.

It doesn't help to make the Driver methods synchronized,
because there are two instances of the driver object :-(
you would have to lock the global configuration data so
that the second thread would have to wait until the first
finishes processing. Of course, this nullifies the advantages
of using multithreading, especially on MP machines.

I like the approach JAXP did for transformers. You have
a factory where you can set default stuff so that you
don't have to do this every time an individual processor
is created, and you can override settings on the individual
instances. The individual processor instances never access
global data after creation.

Does this answer your question(s)?

J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to