let cell x =
let getCh = new_channel () in
let putCh = new_channel () in
let rec loop_ex fix x =
select [
wrap (send getCh fix) (fun () -> loop_ex fix x);
wrap (receive putCh) (loop_ex fix)
] in
let rec loop x =
select [
wrap (send getCh x) (fun () -> loop x);
wrap (receive putCh) (fun fix-> loop_ex fix fix)
] in
ignore (Thread.create loop x);
{ getCh = getCh; putCh = putCh }

let _ =
let c = cell 10 in
Printf.printf "v=%d\n" (get c) ;
put c 20;
Printf.printf "v=%d\n" (get c) ;
put c 10;
Printf.printf "v=%d\n" (get c) ;

一応、結果は10,20,20と出る

>>273
よくわからないけれど正解なんだろうね・・・
数学ワカンネ