Home Contents Index Summary Previous Next

8.5 Thread-support library(threadutil)

This library defines a couple of useful predicates for demonstrating and debugging multi-threaded applications. This library is certainly not complete.

threads
Lists all current threads and their status. In addition, all `zombie' threads (finished threads that are not detached, nor waited for) are joined to reclaim their resources.

interactor
Create a new console and run the Prolog toplevel in this new console. See also attach_console/0. In the Windows version a new interactor can also be created from the Run/New thread menu.

attach_console
If the current thread has no console attached yet, attach one and redirect the user streams (input, output, and error) to the new console window. On Unix systems the console is an xterm application. On Windows systems this requires the GUI version plwin.exe rather than the console based plcon.exe.

This predicate has a couple of useful applications. One is to separate (debugging) I/O of different threads. Another is to start debugging a thread that is running in the background. If thread 10 is running, the following sequence starts the tracer on this thread:


?- thread_signal(10, (attach_console, trace)).