Saxon 9编译转换的线程安全性



使用Saxon 9he,需要几秒钟来编译样式表(在。net中)。

可以验证编译后的转换是线程安全的吗?例如,如果我编译样式表并保留实例以供将来调用。从多个线程同时调用这个编译的Transform实例会导致任何问题吗?

XsltTransformer transformer = proc.NewXsltCompiler().Compile(new Uri("file:///" + styleSheet)).Load();
//Store transformer instance as class variable and reuse it to eliminate compilation time

查看saxonica.com上的文档,您只需要编译一次XsltExecutable ex = proc.NewXsltCompiler().Compile(new Uri("file:///" + styleSheet));,然后可以在几个线程中使用XsltExecutable: "一个XsltExecutable是不可变的,因此是线程安全的。".

关于XsltTransformer,它说"一个XsltTransformer不应该在多个线程中并发使用。但是,在单个线程中重用对象以多次运行相同的样式表是安全的。".

最新更新