Re: thread_detach and Windows

Haitao Zhang <[email protected]> Sun, 20 Apr 2014 11:40:23 -0700
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAFUyvhreBPtXG0pDo4EyM-vH78b9wqj-aVcWfTCaKqFe6h+Q1A@mail.gmail.com>
I found my mistakes. thread_detach appears to work fine on Windows.

My mistake #1: when calling thread_create I used [detach(true)] instead of
[detached(true)]. This was a typo that was silently ignored.

My mistake #2: (using manual detach) following the example in
prolog_server.pl, I called the following sequence during clean up:

   close(InStream),
    close(OutStream),
    thread_detach(Id)

However the stream has already closed due to some exception(?) so
thread_detach doesn't get called. So one should call thread_detach first or
just create the thread detached.

Haitao


On Sat, Apr 19, 2014 at 7:02 PM, Haitao Zhang <[email protected]> wrote:

> Does thread_detach works on Windows? I created a thread with
> detached(true), and later called thread_signal(Alias, thread_exit(true)),
> but I could still see it through thread_property with status(exited(true))
> and detached(false). Other threads that supposedly called thread_detach
> manually also showed up, even though they had status(exception(error(_))).
>
> I am trying to understand how to properly shut down threads.
>
> Thanks,
> Haitao
>
-------------- next part --------------
HTML attachment scrubbed and removed