From: Joel VanderWerf Date: 2003-01-13T06:11:13+09:00 Subject: waiting for a file lock without blocking other threads Is there a way to wait for a file lock without blocking other threads in the same ruby process? The best I could come up with is if Thread.list.size == 1 flock(LOCK_EX) else period = 0.001 until flock(LOCK_SH|LOCK_NB) sleep period period *= 2 if period < 1 end end (I'm using the exponential so that it checks frequently for a while, but gradually uses less and less cpu, down to once per second.) I guess this really boils down to not having native threads. What I was looking for was something like #select, but for file locks. But I can't see how that would be implemented without the ruby interpreter being thread-safe. A related question: There are warnings that flock doesn't work correctly with Linux NFS, and that fcntl should be used instead. Anyone have any experience with this?