src/windows/bin/java_md.c
int
ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
    int rslt = 0;
    unsigned thread_id;

#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
#define STACK_SIZE_PARAM_IS_A_RESERVATION  (0x10000)
#endif

    /*
     * STACK_SIZE_PARAM_IS_A_RESERVATION is what we want, but it's not
     * supported on older version of Windows. Try first with the flag; and
     * if that fails try again without the flag. See MSDN document or HotSpot
     * source (os_win32.cpp) for details.
     */
    HANDLE thread_handle =
      (HANDLE)_beginthreadex(NULL,
                             (unsigned)stack_size,
                             continuation,
                             args,
                             STACK_SIZE_PARAM_IS_A_RESERVATION,
                             &thread_id);
    if (thread_handle == NULL) {
      thread_handle =
      (HANDLE)_beginthreadex(NULL,
                             (unsigned)stack_size,
                             continuation,
                             args,
                             0,
                             &thread_id);
    }

    /* AWT preloading (AFTER main thread start) */
#ifdef ENABLE_AWT_PRELOAD
    /* D3D preloading */
    if (awtPreloadD3D != 0) {
        char *envValue;
        /* D3D routines checks env.var J2D_D3D if no appropriate
         * command line params was specified
         */
        envValue = getenv("J2D_D3D");
        if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
            awtPreloadD3D = 0;
        }
        /* Test that AWT preloading isn't disabled by J2D_D3D_PRELOAD env.var */
        envValue = getenv("J2D_D3D_PRELOAD");
        if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
            awtPreloadD3D = 0;
        }
        if (awtPreloadD3D < 0) {
            /* If awtPreloadD3D is still undefined (-1), test
             * if it is turned on by J2D_D3D_PRELOAD env.var.
             * By default it's turned OFF.
             */
            awtPreloadD3D = 0;
            if (envValue != NULL && JLI_StrCaseCmp(envValue, "true") == 0) {
                awtPreloadD3D = 1;
            }
         }
    }
    if (awtPreloadD3D) {
        AWTPreload(D3D_PRELOAD_FUNC);
    }
#endif /* ENABLE_AWT_PRELOAD */

    if (thread_handle) {
      WaitForSingleObject(thread_handle, INFINITE);
      GetExitCodeThread(thread_handle, &rslt);
      CloseHandle(thread_handle);
    } else {
      rslt = continuation(args);
    }

#ifdef ENABLE_AWT_PRELOAD
    if (awtPreloaded) {
        AWTPreloadStop();
    }
#endif /* ENABLE_AWT_PRELOAD */

    return rslt;
}
/*
 * Block current thread and continue execution in a new thread
 */
Block current thread and continue execution in a new thread
Block current thread and continue execution in a new thread
int
ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
    int rslt = 0;
    unsigned thread_id;
#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
#define STACK_SIZE_PARAM_IS_A_RESERVATION  (0x10000)
#endif
    HANDLE thread_handle =
      (HANDLE)_beginthreadex(NULL,
                             (unsigned)stack_size,
                             continuation,
                             args,
                             STACK_SIZE_PARAM_IS_A_RESERVATION,
                             &thread_id);
    if (thread_handle == NULL) {
      thread_handle =
      (HANDLE)_beginthreadex(NULL,
                             (unsigned)stack_size,
                             continuation,
                             args,
                             0,
                             &thread_id);
    }
#ifdef ENABLE_AWT_PRELOAD
    if (awtPreloadD3D != 0) {
        char *envValue;
        envValue = getenv("J2D_D3D");
        if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
            awtPreloadD3D = 0;
        }
        envValue = getenv("J2D_D3D_PRELOAD");
        if (envValue != NULL && JLI_StrCaseCmp(envValue, "false") == 0) {
            awtPreloadD3D = 0;
        }
        if (awtPreloadD3D < 0) {
            awtPreloadD3D = 0;
            if (envValue != NULL && JLI_StrCaseCmp(envValue, "true") == 0) {
                awtPreloadD3D = 1;
            }
         }
    }
    if (awtPreloadD3D) {
        AWTPreload(D3D_PRELOAD_FUNC);
    }
#endif 
    if (thread_handle) {
      WaitForSingleObject(thread_handle, INFINITE);
      GetExitCodeThread(thread_handle, &rslt);
      CloseHandle(thread_handle);
    } else {
      rslt = continuation(args);
    }
#ifdef ENABLE_AWT_PRELOAD
    if (awtPreloaded) {
        AWTPreloadStop();
    }
#endif 
    return rslt;
}
int ContinueInNewThread0 ( int ( JNICALL * continuation ) ( void * ) , jlong stack_size , void * args ) { int rslt = 0 ; unsigned thread_id ; #ifndef STACK_SIZE_PARAM_IS_A_RESERVATION #define STACK_SIZE_PARAM_IS_A_RESERVATION   (0x10000) #endif HANDLE thread_handle = ( HANDLE ) _beginthreadex ( NULL , ( unsigned ) stack_size , continuation , args , STACK_SIZE_PARAM_IS_A_RESERVATION , & thread_id ) ; if ( thread_handle == NULL ) { thread_handle = ( HANDLE ) _beginthreadex ( NULL , ( unsigned ) stack_size , continuation , args , 0 , & thread_id ) ; } #ifdef ENABLE_AWT_PRELOAD if ( awtPreloadD3D != 0 ) { char * envValue ; envValue = getenv ( " " ) ; if ( envValue != NULL && JLI_StrCaseCmp ( envValue , " " ) == 0 ) { awtPreloadD3D = 0 ; } envValue = getenv ( " " ) ; if ( envValue != NULL && JLI_StrCaseCmp ( envValue , " " ) == 0 ) { awtPreloadD3D = 0 ; } if ( awtPreloadD3D < 0 ) { awtPreloadD3D = 0 ; if ( envValue != NULL && JLI_StrCaseCmp ( envValue , " " ) == 0 ) { awtPreloadD3D = 1 ; } } } if ( awtPreloadD3D ) { AWTPreload ( D3D_PRELOAD_FUNC ) ; } #endif if ( thread_handle ) { WaitForSingleObject ( thread_handle , INFINITE ) ; GetExitCodeThread ( thread_handle , & rslt ) ; CloseHandle ( thread_handle ) ; } else { rslt = continuation ( args ) ; } #ifdef ENABLE_AWT_PRELOAD if ( awtPreloaded ) { AWTPreloadStop ( ) ; } #endif return rslt ; }
Block current thread and continue execution in a new thread
Block current thread and continue execution in a new thread
/*
     * STACK_SIZE_PARAM_IS_A_RESERVATION is what we want, but it's not
     * supported on older version of Windows. Try first with the flag; and
     * if that fails try again without the flag. See MSDN document or HotSpot
     * source (os_win32.cpp) for details.
     */ /* AWT preloading (AFTER main thread start) */ /* D3D preloading */ /* D3D routines checks env.var J2D_D3D if no appropriate
         * command line params was specified
         */ /* Test that AWT preloading isn't disabled by J2D_D3D_PRELOAD env.var */ /* If awtPreloadD3D is still undefined (-1), test
             * if it is turned on by J2D_D3D_PRELOAD env.var.
             * By default it's turned OFF.
             */ /* ENABLE_AWT_PRELOAD */ /* ENABLE_AWT_PRELOAD */