0
如果我有这样的方法:锁实现基于状态
public class Main()
{
public void Start()
{
if(//Check if another thread already invoked this method and its in processing//)
DoSomething();
}
void DoSomething()
{
//Some code in here
}
}
如何使用锁来检查如果一个线程已经在执行时DoSomething的(),然后跳过它?
我知道锁会让其他呼叫等待,但我想跳过而不是等待并执行。
如果在锁定释放后再次调用该方法会怎样? – cassandrad
第一次尝试调用获取应该获得锁定 – Puneet