- if (argc == 0) {
- context->jprocess = (jobject) code;
- }
- else {
- context->jprocess = NULL;
- }
- context->super.cleanup_func = cleanup_func;
- context->begin = xbt_os_sem_init(0);
- context->end = xbt_os_sem_init(0);
-
- context->super.argc = argc;
- context->super.argv = argv;
- context->super.code = code;
-
- context->thread = xbt_os_thread_create(NULL,smx_ctx_java_thread_run,context,NULL);
+ if (argc == 0) {
+ context->jprocess = (jobject) code;
+ }
+ else {
+ context->jprocess = NULL;
+ }
+ context->super.cleanup_func = cleanup_func;
+ context->begin = xbt_os_sem_init(0);
+ context->end = xbt_os_sem_init(0);
+
+ context->super.argc = argc;
+ context->super.argv = argv;
+ context->super.code = code;
+
+ TRY {
+ context->thread = xbt_os_thread_create(NULL,smx_ctx_java_thread_run,context,NULL);
+ } CATCH(e) {
+ RETHROWF("Failed to create context #%d. You may want to switch to Java coroutines to increase your limits (error: %s)."
+ "See the Install section of simgrid-java documentation (in doc/install.html) for more on coroutines.",
+ thread_amount);
+ }