From jan@swi.psy.uva.nl Thu Sep 27 14:04:20 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f8RC4Kv20771;
	Thu, 27 Sep 2001 14:04:20 +0200 (MET DST)
Received: from localhost (localhost [[UNIX: localhost]])
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f8RC4KL28229;
	Thu, 27 Sep 2001 14:04:20 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Organization: SWI, University of Amsterdam
To: "Douglas R. Miles" <dmiles@teknowledge.com>,
   SWI Prolog <prolog@swi.psy.uva.nl>
Subject: RE: [SWIPL] Thread Create using Sockets
Date: Thu, 27 Sep 2001 13:57:11 +0200
X-Mailer: KMail [version 1.0.29.2]
Content-Type: text/plain
References: <EE25484266A64A47AE06CFC47C64232B403B01@helium.teknowledge.com>
In-Reply-To: <EE25484266A64A47AE06CFC47C64232B403B01@helium.teknowledge.com>
MIME-Version: 1.0
Message-Id: <01092714042000.28162@gollem>
Content-Transfer-Encoding: 8bit

On Wed, 26 Sep 2001, Douglas R. Miles wrote:
>Hi,
>
>The program below seems to work:
>
>But I am wondering if the socket_in/1,socket_out/1 and answer_yes are
>exclusive to each thread?

No, the database is shared between all threads.  You can use
thread_self/1 to label facts with the thread identifier.

>(Partially because I am new to using with_mutex/2.)
>
>Also is "threads,  % Free Up Complete Threads" necessary?  Is there a way I
>can call it that doesn't write to std*? 

threads/0 is a utility predicate meant for the toplevel to look at
the status or running threads.  Normally you have either a thread
waiting for the completion using thread_join or, if nobody is interested
in the completion you use the creation-option detached(true), which
makes the thread disappear completely once its main goal terminates
(succeeds, fails or raises an uncaught exception).

In some test applications I had a thread waiting for the others.
If a thread completed it sent a message to this waiting thread,
which in turn updated a list of running threads and joined the
completed thread.

	Regards --- Jan

