Larry Brasfield said:
I would have to qualify that assurance. If you are using
either the multi-threaded static form of the C runtime,
or its multi-threaded DLL form, then there should be
no problem with using the allocator from multiple threads.
However, if you link against the single-threaded static
form of the CRT, then it would be prudent to avoid
using the allocation routines, along with many others
that are designed for only single-threaded use.
All very true. But realize the the recent tools don't even let you call
__beginthreadex() when building against the single threaded runtime. Yes, I
know, that still leaves Win32's CreateThread() to cause grief. OP, if you
are "listening", forget CreateThread() exists; using it is _almost_ always
the wrong thing to use in a C or C++ application.
It's always a fine line to walk providing advice here. There is rarely a
question that can be answered adequately in a line or two. Too much
information increases the chances that the OP won't understand. That's why I
used the qualifier, "generally" and tried to steer the OP away from try to
sharing runtime widgets across a DLL boundary.
I would agree with that statement provided no call
into the allocator is active.
I'm not sure I get you here. Do you mean that you have to prevent one thread
from deleting an object to which another holds a pointer? If so, I heartily
agree. But that's just one example of the kinds of things to consider in a
multi-threaded environment. No matter which runtime the OP uses, he has to
synchronize access to the "updates" of the objects he shares among threads
just as the runtime does. But the mere choice of proper runtime won't do
that for him.
Regards,
Will