By binding *inferencing-state* around specific KnowledgeWorks operations in a function as in the example below, multiple inferencing states can be maintained within a single thread.
(defun test-stepping-single-context ()
(let ((state1 (make-inferencing-state 'state1))
(state2 (make-inferencing-state 'state2)))
(unwind-protect
(progn
(let ((*inferencing-state* state1))
(make-instance 'step-controller
:kb-name 'stepper-one-a))
(let ((*inferencing-state* state2))
(make-instance 'step-controller
:kb-name 'stepper-one-b))
(loop repeat 10
do
(let ((*inferencing-state* state1))
(infer))
(let ((*inferencing-state* state2))
(infer))))
(destroy-inferencing-state state1)
(destroy-inferencing-state state2))))
KnowledgeWorks and Prolog User Guide (Unix version) - 6 Dec 2011