This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other Java Products and Servers and the fly likes jess! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "jess!" Watch "jess!" New topic
Author

jess!

assia assiatoune
Greenhorn

Joined: Jul 11, 2004
Posts: 16
hello !
I am going to ask you a question that I had asked you before.It is about halting the inference engine!!
what did you mean by (if I call the inference from two threads ,all shall be well!)?
do you mean by this sentence that i must have two rete engines for example:
I have two Buttons:
jButton1 and jButton2
and if I click on the first button I have:
jess.Rete r1 = new rete();
r1.executeCommand("batch ....................../zebra.clp");//for example
and if I click on the second button I have:
jess.Rete r2 = new rete();
// and from r2 I have to call the commande
r2.executeCommand("halt");
I had tried with this short example program but the inference would not stop.


the second question is how to activate it after suspending(stopping)it.

I'm waiting for you answers.
thank you. luyza

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

First of all, you should never do anything so time-consuming as running a rule engine inside an event handler, because while an event handler is running, no other GUI actions (including repainting the screen, or handling other events) can occur. Furthermore, if you're running an inference engine in an event handler, than nothing you can implement via another button push can possibly have any effect on that engine, because, as I said, while the first event handler is running, no other event handlers can be serviced. Your "halt" call can't execute until after the inference engine stops by itself. You want the run() call and the halt() call to be executed by different threads. One way to accomplish this (the right way!) would be to have the event handler that starts the engine create a new Thread, and start the engine from the run() method of that Thread.

Finally, you have to call halt() on the instance of Rete that's actually running -- not a separate one created for this purpose. That suggests that the Rete object should be held not in a local variable, but in a member variable, where all your code can get access to it.

I'm not trying to be mean, and I hope I don't hurt your feelings, but it really sounds to me as if the problem here is that you don't have much knowledge of Java itself. I can't really answer your questions well if you don't yet understand the necessary background. JavaRanch is a great place to ask questions about Java -- head over to the Java in General (Intermediate) forum, the Swing/AWT forum, and/or the Threads and Synchronization forum to ask general Java questions that are relevant;. Furthermore, I'd say you need a good Java book or two -- have a look through the JavaRanch Bunkhouse for our recommendations.


[Jess in Action][AskingGoodQuestions]
 
jQuery in Action, 2nd edition
 
subject: jess!
 
Similar Threads
performance issue in iterating through large list of result set
Question on static
questions about JESS,
DanChisholm mock exam question
Object pass by value