A Rete object has basically three synchronization mutexes:
1) One is on the Rete network, (actually the ReteCompiler object) so that only one fact may be asserted or removed at a time. Calls to assert() or retract() will block while another assert() or retract() is executing. 2) Another is on the Agenda, and this one is used such that only one thread can call run() at a time. The agenda can be modified during a run; this is controlled by yet another lock, on the HeapPriorityQueue object inside the Agenda. 3) One is on executeCommand(), so that only one thread can be in an executeCommand() call at one time. So your assumption that no facts can be asserted during a run is false, if you're assuming that Jess will enforce this behavior. Jess allows facts to be asserted while an engine is running. Your second thread could call runUntilHalt() so that the engine ran continuously. If you wanted Jess to behave this way, you could certainly do your own synchronization between your two threads using your own lock. Does this answer your question? I think Gang Liu wrote: > hi, all > Thanks for your help in advance. > > Scenario: > ======= > We have one thread to assert facts constantly to Jess and this thread > doesn't start Jess engine to run. We have another thread to run Jess engine > by (run) once a while. We have a rule whose RHS has a time-consuming > operation. Those facts will trigger the rule. > > Our Assumption: > ============ > In one round of running jess engine, we assume no new facts can be asserted. > When Jess starts, it will only process all facts available at the time of > starting point. > > Observation: > ========= > During that time-consuming operation, new facts are added. And, in the same > round of jess run, those new facts are processed also. > > > More questions: > =========== > Can you tell us how those threads are coordinated by Jess engine? > > thanks > gang --------------------------------------------------------- Ernest Friedman-Hill Distributed Systems Research Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 Org. 8920, MS 9012 [EMAIL PROTECTED] PO Box 969 http://herzberg.ca.sandia.gov Livermore, CA 94550 -------------------------------------------------------------------- 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] --------------------------------------------------------------------
