当有多个文件等待锁定时,flock 是否维护队列?

问题描述

如果有人能帮助我了解 flock 的功能,那就太好了。让我们说我有以下场景:

process A opens the lock file,finds it does not exists,so it creates it.
process A acquires the lock
process B opens the lock (finds it already exists)
process B tries to acquire the lock but has to wait-- Wait 1
process C opens the lock (finds it already exists)
process C tries to acquire the lock but has to wait-- Wait 2
process D opens the lock (finds it already exists)
process D tries to acquire the lock but has to wait-- Wait 3

基于上面的场景,有3个进程在等待获取锁。我的问题是,一旦进程 A 释放锁,等待的作业将如何处理?是先进先出吗?

谢谢, 凯文

解决方法

我尝试用一​​个工作示例脚本测试这个场景,我发现等待的作业是以随机方式处理的。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...