• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

jess!

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Legend has it that if you rub the right tiny ad, a genie comes out.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic