Gotcha. Nothing in POI is thread-safe. No big deal, it is faster/cleaner
to only synchronize what needs to be threadsafe in the application anyhow.
> "Does this mean that I can't use HSSF in servlets where requests come in
> threads?"
>
> - No. You can. Each thread has a separate instance of HSSF and no two
> instances attempt to modify the same file
This is the exact scenario I am dealing with. I could have a situation
where modification of the same file is going to happen. Thanks for the
insights, this won't be difficult to deal with.
--Nathan
----- Original Message -----
From: "Andrew C. Oliver" <[EMAIL PROTECTED]>
To: "POI Users List" <[EMAIL PROTECTED]>
Sent: Wednesday, May 21, 2003 11:04 AM
Subject: Re: Thread issues
> Avoid saying this loudly because most people don't actually know what it
> means but neither POIFS nor HSSF are thread-safe nor are they intended to
> be.
>
> Now I will answer the next 5-10 impending questions:
>
> "Does this mean that I can't use HSSF in servlets where requests come in
> threads?"
>
> - No. You can. Each thread has a separate instance of HSSF and no two
> instances attempt to modify the same file
>
> "Does this mean that I can't use HSSF near my threads that I launched"
>
> -No. It strictly means that no two threads can access the same instance
of
> HSSFWorkbook or write to the same file at the same time or you'll get
nasty
> errors.
>
> "Why don't you just synchronize every method"
>
> -That would be silly and bad (this would have a performance cost too).
You
> however can wrap whatever you're doing with every method synchronized.
>
> "But I don't like it"
>
> - I'm sorry. When you port a low level binary format to Java I'm sure it
> will be much better despite your lack of understanding of what
thread-safety
> means.."
>
> ;-)
>
> -Andy
>
>
> On 5/21/03 9:14 AM, "Danny Mui" <[EMAIL PROTECTED]> wrote:
>
> > When testing stuff, I continually new HSSFWorkbook() files with it being
> > open in Excel. I haven't encountered any locking issues there. Though
> > that's not the same as 2 threads accessing the file through POI, it's
> > something of a starting point. I'm going to be running the same
> > environment you mentioned so it would great if you can share your
results!
> >
> > danny
> >
> > Nate wrote:
> >
> >> Hi all,
> >>
> >> I am currently using POI in a web application that is deployed on
> >> Tomcat. Being multithreaded and all, I have a question about threading
and
> >> POI. I have a template file that is used by my application to build
> >> spreadsheets on the fly. I am currently opening this as a
POIFSFileSystem
> >> object, and passing that to the HSSFWorkbook constructor. If two (or
more)
> >> of my users try to create spreadsheets from the same template
concurrently,
> >> wouldn't the way I am doing things now present a problem? I had
thought
> >> about wrapping them in class that has a method like:
> >>
> >> public synchronized POIFSFileSystem getFS() {
> >> return fs;
> >> }
> >>
> >> to synchronize the POIFS object. Can anyone see a problem with this?
I
> >> understand that it could impact performance, with other threads waiting
on
> >> the filesystem object to read.
> >>
> >> Thanks for your help (again ;-)
> >>
> >> Nathan McMinn
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> --
> Andrew C. Oliver
> http://www.superlinksoftware.com/poi.jsp
> Custom enhancements and Commercial Implementation for Jakarta POI
>
> http://jakarta.apache.org/poi
> For Java and Excel, Got POI?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]