Hi, I am trying to find the most simple and, if possible, clean way to synchronize my threads. In this particular case, semaphores would be ideal (alternatively, unbounded channels) (* Create a new semaphore with a given initial value. *) val create : int -> t (* V *) val up : t -> unit (* P *) val down : t -> unit val try_down : t -> bool The "down" or "try_down" are almost the solutions, but not quite. "down" may block forever ---> there is no timeout at all (I need some) "try_down" ---> the timeout is zero (I prefer a non-zero timeout) Obviously, I could use "try_down" in a loop, checking the system time myself and then either give up or actually manage to decrement the semaphore. Is there a better solution than this? (There is a Unix module, there are signals, but I am not sure whether it is safe to use them in multithreaded program. At least, I did not have a luck.) Thanks in advance for patience &| help.