name: duk_push_thread_new_globalenv proto: | duk_idx_t duk_push_thread_new_globalenv(duk_context *ctx); stack: | [ ... ] -> [ ... thr! ] summary: |

Push a new Duktape thread (context, coroutine) to the stack. Returns non-negative index (relative to stack bottom) of the pushed thread. The new thread will be associated with the same Duktape heap as the argument ctx, but will have a new global object environment (separate from the one used by ctx).

To interact with the new thread with the Duktape API, use duk_get_context() to get a context pointer for API calls.

example: | duk_idx_t thr_idx; duk_context *new_ctx; thr_idx = duk_push_thread_new_globalenv(ctx); new_ctx = duk_get_context(ctx, thr_idx); tags: - stack - thread - borrowed seealso: - duk_push_thread introduced: 1.0.0