参数为:ciMultiInstance, tmApartment创建RDM则应该是并发的,我以前测试过确实是并发的,因为TComponentFactory这个类工厂使用了TApartmentThread来创建RDM实例,不过它默认的是tmApartment这种线程模式,所以你换成tmNeutral就不能使用TApartmentThread来创建RDM实例,这时候就是顺序的创建RDM,而不是由TApartmentThread产生一个TApartmentThread线程再由这个线程来创建RDM实例
function TComponentFactory.CreateInstance(const UnkOuter: IUnknown;
const IID: TGUID;
out Obj): HResult;
stdcall;
begin
if not IsLibrary and (ThreadingModel = tmApartment) then
begin
LockServer(True);
try
with TApartmentThread.Create(Self, UnkOuter, IID)do
begin
if WaitForSingleObject(Semaphore, INFINITE) = WAIT_OBJECT_0 then
begin
Result := CreateResult;
if Result <>
S_OK then
Exit;
Result := CoGetInterfaceAndReleaseStream(IStream(ObjStream), IID, Obj);
end else
Result := E_FAIL
end;
finally
LockServer(False);
end;
end else
Result := inherited CreateInstance(UnkOuter, IID, Obj);
end;
如果你要并发,要么就改你的线程模式要么就修改TComponentFactory中的vcl源码或者创建自己的类工厂