windows - C/C++: duplicate main() loop in many threads -


I have this "interesting" problem. I have this legacy code that looks

  Int main () {while (true) {doSomething (); }}  

I want to duplicate doSomething () in multiple threads, so that now looks like the main ()

  int main () {RunManyThreads (threadEntry }} Zero thread entry () {while (true) {doSomething (); }}  

The problem is that doSomething () uses many global and stable variables, and I can not change its code. Is there any move to duplicate those static variables, so each thread has its own set? (Thread some kind of local storage, but without affecting doSomething ()) I use VisualC ++

To make a long story short, no, not least ( What i called) reasonably

Do not want to change doSomething () , your best bet is probably to run multiple copies of the current process instead of trying to use multi-threading if Each thread is going to use a different copy of the global variable, and in this way, the difference between multithreading and multiple processes will be quite modest in any case.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -