Thread safety in Visual Prolog


Revision as of 16:18, 19 February 2019 by Thomas Linder Puls (talk | contribs) (threadsafe facts)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Thread safe:

  • Access facts

Not thread safe:

  • GUI
  • Streams
  • odbcConnection/odbcStatement


See Threadsafe facts.


Windows GUI is not thread safe, only the thread that runs the message pump of a window should accees that window. In Visual Prolog all windows (except modal dialogs) belong to the thread that have executed the vpi::init call.

Synchronization back to the GUI thread can be done using window::postAction, because the posted action will be executed by the GUI thread.

Modal dialogs run their own message pump and they are therefore owned by the thread that displays them.


Streams are in general not thread safe, but specific streams can be.

From Visual Prolog 7.4 the thread on messageControls are thread safe. In a GUI application stdio will thus be thread safe while it is redirected to a messageControl/messageForm, but if it is redirected to some other stream it will "inherit" the thread safety from that stream.


An odbcConnection/odbcStatement is not thread safe, but different odbcConnection's/odbcStatement's can be accessed in parallel.