Changeset 7035

Show
Ignore:
Timestamp:
06/27/07 19:05:56
Author:
robert
Message:

From Daniel Kallfass, "Threads were created using CreateThread(, which have caused some
problems with the c run-time library in our application (e.g. crashes
when calling getEnv()). Now it uses _beginthreadex() instead of
CreateThread() to ensure that the c-runtime is initialized correctly for
a multithreaded environment."

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • OpenThreads/trunk/src/OpenThreads/win32/Win32Thread.cpp

    r6584 r7035  
    1919#include <string> 
    2020#include <iostream> 
     21#include <process.h> 
    2122 
    2223#if defined(_MSC_VER) && (_MSC_VER < 1300) 
     
    8889        // Win32Threads standard start routine. 
    8990        // 
    90         static unsigned long __stdcall StartThread(void *data) { 
     91        static unsigned int __stdcall StartThread(void *data) { 
    9192 
    9293            Thread *thread = static_cast<Thread *>(data); 
     
    319320    // 2) if not than we're in trouble anyway - nothing is protected  
    320321    // pd->stackSizeLocked = true; 
    321     unsigned long ID; 
    322  
    323     pd->tid.set( CreateThread(NULL,pd->stackSize,ThreadPrivateActions::StartThread,static_cast<void *>(this),0,&ID)); 
     322    unsigned int ID; 
     323 
     324    pd->tid.set( (void*)_beginthreadex(NULL,pd->stackSize,ThreadPrivateActions::StartThread,static_cast<void *>(this),0,&ID)); 
    324325 
    325326    pd->uniqueId = (int)ID;