javar/jdk8-analysis/src/launcher/java_md_solinux.c
/*
 * 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;
#ifndef __solaris__
    pthread_t tid;
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    if (stack_size > 0) {
      pthread_attr_setstacksize(&attr, stack_size);
    }
    if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
      void * tmp;
      pthread_join(tid, &tmp);
      rslt = (int)tmp;
    } else {
      rslt = continuation(args);
    }
    pthread_attr_destroy(&attr);
#else 
    thread_t tid;
    long flags = 0;
    if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
      void * tmp;
      thr_join(tid, NULL, &tmp);
      rslt = (int)tmp;
    } else {
      rslt = continuation(args);
    }
#endif 
    return rslt;
}
int ContinueInNewThread0 ( int ( JNICALL * continuation ) ( void * ) , jlong stack_size , void * args ) { int rslt ; #ifndef __solaris__ pthread_t tid ; pthread_attr_t attr ; pthread_attr_init ( & attr ) ; pthread_attr_setdetachstate ( & attr , PTHREAD_CREATE_JOINABLE ) ; if ( stack_size > 0 ) { pthread_attr_setstacksize ( & attr , stack_size ) ; } if ( pthread_create ( & tid , & attr , ( void * ( * ) ( void * ) ) continuation , ( void * ) args ) == 0 ) { void * tmp ; pthread_join ( tid , & tmp ) ; rslt = ( int ) tmp ; } else { rslt = continuation ( args ) ; } pthread_attr_destroy ( & attr ) ; #else thread_t tid ; long flags = 0 ; if ( thr_create ( NULL , stack_size , ( void * ( * ) ( void * ) ) continuation , args , flags , & tid ) == 0 ) { void * tmp ; thr_join ( tid , NULL , & tmp ) ; rslt = ( int ) tmp ; } else { rslt = continuation ( args ) ; } #endif return rslt ; }
Block current thread and continue execution in a new thread
Block current thread and continue execution in a new thread
/*
      * Continue execution in current thread if for some reason (e.g. out of
      * memory/LWP)  a new thread can't be created. This will likely fail
      * later in continuation as JNI_CreateJavaVM needs to create quite a
      * few new threads, anyway, just give it a try..
      */ /* __solaris__ */ /* See above. Continue in current thread if thr_create() failed */ /* !__solaris__ */