[英]Ocaml Thread misunderstanding
我仅在5秒钟的延迟后才能看到整个输出,但我认为应该是这样。
我期望以下输出:
主要在这里
您好收到
( 然后才睡5秒钟 )
但是我的代码首先要休眠5秒钟,然后才继续。
let t1 ch =
let m = sync (receive ch) in
print_string (m ^ " -> received\n");
delay 5.0;
sync (send ch "t1 got the message")
let main () =
let ch = new_channel () in
create t1 ch;
print_string "main is here\n";
sync (send ch "hi");
print_string ("main confirms :" ^ sync(receive ch))
我很乐意在线阅读一些教程,但没有找到任何教程。
尝试刷新输出
print_string "main is here\n";
flush stdout
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.