Greetings!

Of course I am fully aware that POI is not thread safety on workbook
level and threads can only be used as long as every sheet is processed
within its own thread (without altering styles).
Still I ran into a small problem when processing several sheets in
parallel: After creating all styles, I opened the threads for each
sheet and CREATED each sheet inside the thread. This failed.

The correct solution was, to

1) Create all Sheets serially (from an Array of names)
2) Spawn the threads (from an Array of names) and
3) inside of each thread, to get the sheet by name

So far so good.

I only wonder, if POI should have blocked Sheet sheet =
workbook.createSheet(p[4]); by itself, e. g. using a semaphore and
print a warning. This would help a) the developers understanding and b)
also ensure, that no undetected mistakes were made when compiling the
workbook.

Please let me know what you think, thanks a lot in advance.
Best regards
Andreas

Reply via email to