NextPrevUpTopContentsIndex

6.5.3.1 Multiple threads

By binding *inferencing-state* around all KnowledgeWorks operations in a thread's main function as in the example below, its value can be unique to each thread.

(defun test-1-counter (name)
  (let* ((*inferencing-state* nil)
         (step (1+ (random 10)))
         (limit (* step (+ 2000 (random 100)))))
    (unwind-protect
        (progn
          (setq *inferencing-state*
                (make-inferencing-state name))
          (make-instance 'counter
                         :value limit
                         :step step)
          (infer))
      (destroy-inferencing-state *inferencing-state*))))
 
(mp:process-run-function (format nil "Test ~D" index)
                         '()
                         'test-1-counter
                         (gensym)

KnowledgeWorks and Prolog User Guide (Macintosh version) - 29 Feb 2008

NextPrevUpTopContentsIndex