From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id BFCB17EE4B for ; Fri, 27 Sep 2013 12:10:24 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of tom.j.ridge@googlemail.com) identity=pra; client-ip=209.85.160.49; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of tom.j.ridge@googlemail.com designates 209.85.160.49 as permitted sender) identity=mailfrom; client-ip=209.85.160.49; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="tom.j.ridge@googlemail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-pb0-f49.google.com) identity=helo; client-ip=209.85.160.49; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="tom.j.ridge@googlemail.com"; x-sender="postmaster@mail-pb0-f49.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar4BAB5ZRVLRVaAxm2dsb2JhbABZgz9SgmO+fQgWDgEBAQEBBgsLCRQogmwBATgQFV0SAQUBIogGAQMPm3yLDIRQAQWECgoZJw2JZAaTdpgAgS+OXxgpgWKCbDs X-IPAS-Result: Ar4BAB5ZRVLRVaAxm2dsb2JhbABZgz9SgmO+fQgWDgEBAQEBBgsLCRQogmwBATgQFV0SAQUBIogGAQMPm3yLDIRQAQWECgoZJw2JZAaTdpgAgS+OXxgpgWKCbDs X-IronPort-AV: E=Sophos;i="4.90,991,1371074400"; d="scan'208";a="34596581" Received: from mail-pb0-f49.google.com ([209.85.160.49]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Sep 2013 12:10:23 +0200 Received: by mail-pb0-f49.google.com with SMTP id xb4so2344446pbc.8 for ; Fri, 27 Sep 2013 03:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=N/OAk2Tt1PH1+q8aeyrd6w+OqbYqmh5xepDHhvsucDs=; b=A6pe8LJkME9SgWb61B4NlpZRsBd5SxosC5ZE5j1CMBG/EyEClev11JDx6s3utl1dTf XWCSS0Af4g1E1LLUccfqcqBhSgPsBYtIprHZetppoUXXm7OSfblqvQFZbfy0poGJni5d J5duGkV1DDfqJTnh9natsREQpNWgGOC+sx8+lK+eX87J5f75rjeOMYs/VHaRPtV4rHrY ea0woGXK7BBHhA9P8GPXGcpiQ5JjZ+w4WJ+MykkEiS1KdjC6sVo/bSq04Nj1uxzO8dzA LkC4kyRB1rb5hof52SjrgwGtaeSXz/PxepY+PASPJ4jbcwPNi9NMAvoHVF58bvRoJ9Nc EgHQ== X-Received: by 10.66.7.102 with SMTP id i6mr10585485paa.149.1380276622760; Fri, 27 Sep 2013 03:10:22 -0700 (PDT) MIME-Version: 1.0 Sender: tom.j.ridge@googlemail.com Received: by 10.70.79.136 with HTTP; Fri, 27 Sep 2013 03:10:02 -0700 (PDT) From: Tom Ridge Date: Fri, 27 Sep 2013 11:10:02 +0100 X-Google-Sender-Auth: dULHFZMS4uGo6hFqg4dJR9k7Vgc Message-ID: To: caml-list Content-Type: text/plain; charset=ISO-8859-1 Subject: [Caml-list] Thread behaviour Dear caml-list, I have a little program which creates a thread, and then sits in a loop: -- let f () = let _ = ignore (print_endline "3") in let _ = ignore (print_endline "hello") in let _ = ignore (print_endline "4") in () let main () = let _ = ignore (print_endline "1") in let t = Thread.create f () in (* let _ = Thread.join t in *) let _ = ignore (print_endline "2") in while true do flush stdout; done let _ = main () -- I compile the program with the following Makefile clause: test.byte: test.ml FORCE ocamlc -o $@ -thread unix.cma threads.cma $< When I run the program I get the output: 1 2 and the program then sits in the loop. I was expecting the output from f to show up as well. If you wait a while, it does. But you have to wait quite a while. What am I doing wrong here? I notice that if I put Thread.yield in the while loop then f's output gets printed pretty quickly. But why should the while loop affect scheduling of f's thread? Thanks