Hello,

I am using Jess in a multithreaded environment. My facts are mostly Java objects asserted with deffact, and the right side of rules is usually a single call to a Java method that might add/remove facts.

I need to understand how Jess works in a multithreaded environment. I seem to remember there are 2 locks: one lock for the data model and one for the engine.

Is the following description correct?
- One lock is on all the data (facts, rules, the state of the engine, etc. ) . That means you can do asserts, retracts, deffacts, defrules and such simultaneously in multiple threads without risk.
- A second lock prevents multiple rules to be fired at the same time.

Whether it is correct or not, could you clarify how Jess behaves?

Can I assume that no 2 threads will fire a rule at the same time? While the RHS is being executed, can I assume no other rule will even be considered for firing before the RHS executed, even if run() is called in the meantime in the same thread or another thread?

Will run() be ignored if called from a Java method called from a rule RHS? I tend to do a run() after every update to any fact. But it might well be that the said update was called from the RHS of a rule firing during a run(). Will this cause problems?

If one thread is executing run() (and fires and executes rules) and a second threads calls run(), will they both fire rules or will the first thread to all the work? If yes, will the second thread wait for the first run() to complete, tu guarantees all rules have fired?

If one thread is executing run() (and fires and executes rules) and a second threads does a deffact() or undeffact(), can the facts be updated while a RHS is executing? Or will the facts change between 2 rules firing? Or will the second thread block until run() returns and all rules have fired?

Thanks for clarifications.
Florian Fischer

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to