Multi session / multi-tenant web app with SWI-Prolog

It seems indeed that forking be the best and safest alternative.
Now, from a tomcat/Java point of view, tomcat has already the possibility to fork a process and to call inside that process an application (which chould be a lean swi-prolog application) - or to instantiate a “big” swi-prolog class having all inside, the interpreter … So a tomcat servlet could control this forking.

Do you think I could encapsulate swi-prolog in that way? Could you theoretically / practically provide (maybe there is already) a library from which the “big swi-prolog class” can be instantiated and used (right now I forgot in which language swi-prolog is realised, if not in Java, then shell programming will help (me)). Of course I do not intend to cause (you) work on this, unles this could be generally interesting.