KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
final WorkingMemoryEntryPoint ep = ksession.getWorkingMemoryEntryPoint( "testep" );
List list = new ArrayList();
ksession.setGlobal( "list",
list );
ksession.insert( new Cheese( "cheddar" ) );
ksession.fireAllRules();
Runnable fireUntilHalt = new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
};
Thread t1 = new Thread( fireUntilHalt );
t1.start();
Thread.currentThread().sleep( 500 );
ep.insert( new Person( "darth" ) );
Thread.currentThread().sleep( 500 );
ksession.halt();
t1.join( 5000 );
boolean alive = t1.isAlive();
if ( alive ) {