src/java.base/unix/native/libjli/java_md_solinux.c

Print this page




 871 
 872 /*
 873  * Block current thread and continue execution in a new thread
 874  */
 875 int
 876 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 877     int rslt;
 878 #ifndef __solaris__
 879     pthread_t tid;
 880     pthread_attr_t attr;
 881     pthread_attr_init(&attr);
 882     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 883 
 884     if (stack_size > 0) {
 885       pthread_attr_setstacksize(&attr, stack_size);
 886     }
 887 
 888     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 889       void * tmp;
 890       pthread_join(tid, &tmp);
 891       rslt = (int)tmp;
 892     } else {
 893      /*
 894       * Continue execution in current thread if for some reason (e.g. out of
 895       * memory/LWP)  a new thread can't be created. This will likely fail
 896       * later in continuation as JNI_CreateJavaVM needs to create quite a
 897       * few new threads, anyway, just give it a try..
 898       */
 899       rslt = continuation(args);
 900     }
 901 
 902     pthread_attr_destroy(&attr);
 903 #else /* __solaris__ */
 904     thread_t tid;
 905     long flags = 0;
 906     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
 907       void * tmp;
 908       thr_join(tid, NULL, &tmp);
 909       rslt = (int)tmp;
 910     } else {
 911       /* See above. Continue in current thread if thr_create() failed */




 871 
 872 /*
 873  * Block current thread and continue execution in a new thread
 874  */
 875 int
 876 ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 877     int rslt;
 878 #ifndef __solaris__
 879     pthread_t tid;
 880     pthread_attr_t attr;
 881     pthread_attr_init(&attr);
 882     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 883 
 884     if (stack_size > 0) {
 885       pthread_attr_setstacksize(&attr, stack_size);
 886     }
 887 
 888     if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 889       void * tmp;
 890       pthread_join(tid, &tmp);
 891       rslt = (intptr_t)tmp;
 892     } else {
 893      /*
 894       * Continue execution in current thread if for some reason (e.g. out of
 895       * memory/LWP)  a new thread can't be created. This will likely fail
 896       * later in continuation as JNI_CreateJavaVM needs to create quite a
 897       * few new threads, anyway, just give it a try..
 898       */
 899       rslt = continuation(args);
 900     }
 901 
 902     pthread_attr_destroy(&attr);
 903 #else /* __solaris__ */
 904     thread_t tid;
 905     long flags = 0;
 906     if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
 907       void * tmp;
 908       thr_join(tid, NULL, &tmp);
 909       rslt = (int)tmp;
 910     } else {
 911       /* See above. Continue in current thread if thr_create() failed */