# Multithread Query with JPL

**URL:** <https://swi-prolog.discourse.group/t/multithread-query-with-jpl/3764>\
**Category:** Help!\
**Tags:** how-to\
**Created:** [March 25, 2021, 9:03am UTC](https://swi-prolog.discourse.group/t/multithread-query-with-jpl/3764 "2021-03-25T09:03:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TramsWang](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/tramswang/32/3147_2.png) [@TramsWang](https://swi-prolog.discourse.group/u/TramsWang)\
**Post date:** [March 25, 2021, 9:03am UTC](https://swi-prolog.discourse.group/t/multithread-query-with-jpl/3764/1 "2021-03-25T09:03:26Z")

</div>

I’m using: SWI-Prolog version 8.0.2 and I want to query via JPL in multi-thread programs. Is there any tutorial someone can share?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [March 25, 2021, 9:27am UTC](https://swi-prolog.discourse.group/t/multithread-query-with-jpl/3764/2 "2021-03-25T09:27:34Z")

</div>

Start upgrading to the latest version. Several issues with JPL have been fixed, notably concurrency related issues. JPL’s default model is to maintain a pool of Prolog engines and a call from JPL from any thread uses an arbitrary engine from this pool. So, it “works”, but you have to be careful with (avoid) Prolog thread-local data. The most recent versions of JPL also allow for a one-to-one mapping where a Java thread creates a Prolog engine it talks to (and should discard this engine before the Java thread terminates).

---

<div class="post-metadata">

**Author:** ![TramsWang](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/tramswang/32/3147_2.png) [@TramsWang](https://swi-prolog.discourse.group/u/TramsWang)\
**Post date:** [March 25, 2021, 9:40am UTC](https://swi-prolog.discourse.group/t/multithread-query-with-jpl/3764/3 "2021-03-25T09:40:34Z")

</div>

These features should be what I’m looking for 😁

Is there any guide about how to use these features in JPL? I searched in [SWI-Prolog](https://eu.swi-prolog.org/pldoc/doc_for?object=section(%27packages/jpl.html%27)) but didn’t find introduction of these features.
