Clips / Java/ JNI / Threads

36 views
Skip to first unread message

Blake McBride

unread,
Jan 12, 2025, 9:13:18 AMJan 12
to CLIPSESG
Greetings,

I would like to use CLISP from Java (presumably through JNI).  My question has to do with threads.

My Java program is a web application.  Many users can use the system at the same time - multiple threads.  This leads me to two questions regarding my use of CLIPS.

1.  Will it work in a multi-threading environment?

2.  In other systems I have used (JESS), I was able to define a base set of rules and facts.  Each new thread would start with this base set.  After that, each thread can diverge with regard to rules and facts.  Can I do this through the JNI interface?

Thank you!

Blake McBride

Ryan Johnston

unread,
Jan 12, 2025, 11:01:43 AMJan 12
to clip...@googlegroups.com

1. CLIPS environments are not thread safe, so only execute one operation on a single CLIPS environment at a time.

2. This can be accomplished by using multiple CLIPS environments, one per thread. You could even create a pool of "unused" environments ahead of time, setting up your rules and facts, and then taking an environment from that pool of resources when you need it.

I'm not familiar with jmi, but there are examples in the source code here that might help: https://sourceforge.net/p/clipsrules/code/HEAD/tree/branches/64x/clipsjni/java-src/net/sf/clipsrules/jni/examples/


--
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To post to this group, send email to CLIP...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/CLIPSESG?hl=en
 
--> IF YOU NO LONGER WANT TO RECEIVE EMAIL <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Click on "Edit my membership" link.
Select the "No Email" radio button.
Click the "Save these settings" button.

--> IF YOU WANT TO UNSUBSCRIBE <--
Visit this group at http://groups.google.com/group/CLIPSESG?hl=en
Sign in
Click on "Edit my membership" link.
Click the "Unsubscribe" button.
Note: This appears to be the most reliable way to unsubscribe
 
Alternately, send email to CLIPSESG-u...@googlegroups.com. You will receive an email which you must respond to as well to unsubscribe. Clicking the link mentioned in the unsubscribe reply does not appear to work reliably.
---
You received this message because you are subscribed to the Google Groups "CLIPSESG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clipsesg+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/clipsesg/62503613-22e0-4dab-bec5-9aefb259f139n%40googlegroups.com.

CLIPS Support

unread,
Jan 12, 2025, 12:50:18 PMJan 12
to CLIPSESG
The CLIPSJNI example you want to look at is RouterDemo. It creates two environments and runs each one  in separate panes of the GUI. Each environment you create needs to have rules loaded after it is created, but it is completely separate from other environments, so the rules and facts can be different.

RouterDemo.png
Reply all
Reply to author
Forward
0 new messages