I am curious why bother ?

Why not just create a new compiler object in each thread ?




David A. Lee




From: Archie Cobbs [mailto:archie@dellroad.org]
Sent: Thursday, December 27, 2012 4:54 PM
To: Michael Sokolov
Cc: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] thread-safety of error reporting in Saxon compilers


Sorry, I think I misunderstood what you were saying before.

You want to use a single compiler in different threads, but you want the different compilations' error reports to be separable somehow.

I think the only way to do this is to put a ThreadLocal field into your ErrorListener, and use it to tell which compilation is being notified. This assumes that the compiler is going to notify the ErrorListener from the same thread it is invoked in.


On Thu, Dec 27, 2012 at 1:50 PM, Michael Sokolov <sokolov@ifactory.com> wrote:

On 12/27/2012 11:45 AM, Archie Cobbs wrote:

Isn't that a problem for the ErrorListener, not the compiler?

In other words, if you re-use the same ErrorListener with multiple compilers in multiple threads, then you need to ensure your ErrorListener is thread safe.


Well, that's true in some sense, but the question I have is: is there a way to use the *same* compiler in multiple threads, and also receive errors (with one or multiple ErrorListeners) in a thread-safe manner.


Archie L. Cobbs