Hi,
Not to be overly harsh, but the example is very convoluted and
contains a lot of (almost, and there lies the bigest problem!)
duplicated code. There are many many bugs, but they're hard to
see. I'd suggest that what you need to do is factor things out such
that the duplicated code goes away and code that needs to run more
than once should be in a method you can call twice.
One of the few things that's -not- wrong is your attempt to run two
Jess instances in one application and have them share Beans -- this
works perfectly fine, when the bugs are excised.
In any case, here are a few specifics to illustrate some of the
problems:
- Most seriously, due to a copy and paste error, there are two threads
calling runUntilHalt() on one of the Rete objects, and none on the
other! Examine the two anonymous classes in the App constructor to
see this. If you fix this, then batch your rules into both windows,
you'll see both engines are firing rules faster than the GUI can keep
up (and see below for more on this.) You really should use two
separate rule files, too, since otherwise you start with two Name
objects rather than the one you want.
- Any exceptions thrown by the Rete engines will be discarded without
examination - again, look at those anonymous classes. Clearly, this is
not what you want: makes debugging rather hard. In any case, these
will include runtime exceptions thrown by Swing, and there are plenty,
because...
- ... you can't use Swing this way in a multithreaded application. The
documentation makes it quite clear that you need to use
SwingUtilitites.invokeLater. See
http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html
.
I think S.S.Ozsariyildiz wrote:
> Hi,
>
> I wrote and attached a simple example to experiment Multi threaded
> engines sharing same beans. Basically it is cut and paste from the
> original jess code and examples.
>
> The class App contains to separate threads to JessA and JessB. Both
> engines executes run-until-halt. JessA and JessB shares the class
> Share1. Share1 has synchronized methods put and remove. put method
> creates instances (bean Name.class in this example) in both engines. Now
> the problem is if I put a new Instance of a bean the JessA fires and
> changes the bean which is ok. but the JessB is sharing that bean and it
> should react to JessA and change it as well. However it does nothing!
>
> Any help is welcomed.
> Are there any simple examples with this topic?
>
> Regards S.S. Ozsariyildiz
>
>
>
---------------------------------------------------------
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]
---------------------------------------------------------------------