Subject: Thread problem in 3.3.0

From: Andrey Diatchkov <[email-masked]>
Date: Mon, 31 Jan 2000 17:25:04 +0300 (MSK)

I've written simple example of thread and run it on RedHat 6.1, 
SwiProlog 3.3.0#10. I've got strange result.

There are two thread : main and logger. Main-thread send message to
logger-thread.

main :-
        thread_create(logger,LoggerId,[]),
        main_cycle(LoggerId).

main_cycle(LoggerId) :-
        thread_send_message(LoggerId," first"),
        thread_send_message(LoggerId," second"),
        !,
        main_cycle(LoggerId).

logger :-
        thread_get_message(Info),
        writef(Info),nl,
        logger.

It's right. Result:

 first
 second
 first
 second
 . . .

But if i add sleep() in main_cycle then second message don't
printing (see below):

main_cycle(LoggerId) :-
        thread_send_message(LoggerId," first"),
        thread_send_message(LoggerId," second"),
	sleep(0.1),
        !,
        main_cycle(LoggerId).
Result:
 first
 first
 first
 first
 . . .

Next experiment:

main_cycle(LoggerId) :-
        thread_send_message(LoggerId," first"),
	sleep(0.1),
        thread_send_message(LoggerId," second"),
        sleep(0.1),
        !,
        main_cycle(LoggerId).

It's working right too.

Is it bug?

Thank you.