/** * Creates a new thread that has access to the current language context. A thread is * {@link TruffleLanguage#initializeThread(Object, Thread) initialized} when it is * {@link Thread#start() started} and {@link TruffleLanguage#disposeThread(Object, Thread) * disposed} as soon as the thread finished the execution. In order to start threads the * language needs to {@link TruffleLanguage#isThreadAccessAllowed(Thread, boolean) allow} * access from multiple threads at the same time. * <p> * It is recommended to set an * {@link Thread#setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler) * uncaught exception handler} for the created thread. For example the thread can throw an * uncaught exception if one of the initialized language contexts don't support execution on * this thread. * <p> * The language that created and started the thread is responsible to complete all running * or waiting threads when the context is {@link TruffleLanguage#disposeContext(Object) * disposed}. * * @param runnable the runnable to run on this thread. * @throws IllegalStateException if thread creation is not {@link #isCreateThreadAllowed() * allowed}. * @since 0.28 */ @TruffleBoundary public Thread createThread(Runnable runnable) { return createThread(runnable, null); }
/** * Creates a new thread that has access to the given context. See * {@link #createThread(Runnable, TruffleContext, ThreadGroup, long)} for a detailed * description of the parameters. The <code>stackSize</code> set to 0. * * @see #getContext() * @see #newContextBuilder() * @since 0.28 */ @TruffleBoundary public Thread createThread(Runnable runnable, @SuppressWarnings("hiding") TruffleContext context, ThreadGroup group) { return createThread(runnable, context, group, 0); }
/** * Creates a new thread that has access to the given context. See * {@link #createThread(Runnable, TruffleContext, ThreadGroup, long)} for a detailed * description of the parameters. The <code>group</code> is null and <code>stackSize</code> * set to 0. * * @see #getContext() * @see #newContextBuilder() * @since 0.28 */ @TruffleBoundary public Thread createThread(Runnable runnable, @SuppressWarnings("hiding") TruffleContext context) { return createThread(runnable, context, null, 0); }
/** * Creates a new thread that has access to the current language context. See * {@link #createThread(Runnable, TruffleContext, ThreadGroup, long)} for a detailed * description of the parameters. The <code>group</code> is null and <code>stackSize</code> * set to 0. * * @since 0.28 */ @TruffleBoundary public Thread createThread(Runnable runnable) { return createThread(runnable, null); }