Pierre,<br><br>There is no need to rebuild the entire rules base with each thread. You can build the rule base statically at startup. Then within your thread's just do:<br><br>// Note this is 4.0 syntax:<br>final StatefulSession session =
ruleBase.newStatefulSession();<br><br>A single working memory is thread safe and the call in the ruleBase to create it is as well.<br><br>Ron<br><br><div><span class="gmail_quote">On 7/10/07, <b class="gmail_sendername">Pierre Paysant-Le Roux
</b> <<a href="mailto:pierre.paysant_leroux@travelsoft.fr">pierre.paysant_leroux@travelsoft.fr</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>I have a problem using Drools in a multi thread program. I want that<br>several threads use there own working memory. There is an error when two<br>thread are building the same PackageBuilder at the same time. The<br>
exception is: java.lang.LinkageError: duplicate class definition.<br><br>Here is a simple program that generates the error.<br><br>package com.sample;<br><br>import java.io.IOException;<br>import java.io.InputStreamReader
;<br><br>import org.drools.compiler.DroolsParserException;<br>import org.drools.compiler.PackageBuilder;<br>import org.drools.compiler.PackageBuilderConfiguration;<br><br>public class TestThreads {<br><br> public static void main(String[] args) {
<br> for(int i = 0; i<2 ; i++) {<br> DroolsThread tt = new DroolsThread();<br> tt.start();<br> }<br> }<br><br> public static class DroolsThread extends Thread {<br><br> public void run() {
<br> PackageBuilderConfiguration pkgBuilderCfg =<br> new PackageBuilderConfiguration();<br> PackageBuilder builder = new PackageBuilder(pkgBuilderCfg);<br> try {<br>
builder.addPackageFromDrl(new<br>InputStreamReader(DroolsTest.class.getResourceAsStream( "/Sample.drl" )));<br> } catch (DroolsParserException e) {<br> e.printStackTrace();<br> } catch (IOException e) {
<br> e.printStackTrace();<br> }<br> }<br> }<br>}<br><br><br>I don't understand what to do to avoid the exception : using<br>"synchronized" somewhere ? Can someone help me please ?
<br>Thanks<br>Pierre<br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br>