TInterfacedObject._Release
和TInterfacedObject._AddRef
是线程安全的吗?
我可以看到FRefCount
是线程安全的,但Destroy
没有受到锁或其他保护。
function TInterfacedObject._Release: Integer;
begin
Result := InterlockedDecrement(FRefCount);
if Result = 0 then
Destroy;
end;
不同的线程能够同时执行 Destroy
导致竞争条件吗?