I have a dll with source code that is not thread safe yet. The dll is quite complex and it will take quite a long time to make it thread safe. So i came up with the idea to just run several “copies” of the Dll independently. The easiest thing would probably be to create N renamed copies of the Dll and to load one separate Dll per thread.
Is this a possible solution?
Is there a better similar way?
Is there possibly some wrapper code existing ?
I know that this is not at all a good engineering solution. Please don’t blame me. But it might solve a number of problems.
EDIT 2017
I’ve done this and it works without Problems. Great!
Please note the following though:
http://msdn.microsoft.com/en-us/library/2s9wt68x%28v=vs.80%29.aspx
If a DLL declares any nonlocal data or object as __declspec( thread ), it can cause a protection fault if dynamically loaded.
That solution is perfectly possible and, in my view, is the only viable way to deal with a DLL that has global state that is not thread-safe. It’s not pretty, but it does work.