# task_create

Definition: | integer task_id = task_create(integer rid, sequence args)
Description: | Create a new task. rid: the routine id of a user-defined procedure. args: the list of arguments that will be passed to that procedure when the task starts executing. (refer to call_proc, which is used internally, for more details) The result is a task identifier, required for the other multitasking routines.
pwa/p2js: | Not supported.
Comments: | task_create() creates a new task, but does not start it executing. Each task has its own set of private variables and its own call stack. Global and local variables are shared between all tasks. If a run-time error is detected, the traceback will include information on all tasks, with the offending task listed first. [DEV] Many tasks can be created that all run the same procedure, possibly with different parameters. A task cannot be based on a function, since there would be no way of using the function result.
Example: |
    mytask = task_create(routine_id("myproc"), {5, 9, "ABC"})
Implementation: | See builtins\VM\pTask.e (an autoinclude) for details of the actual implementation.
See Also: | task_schedule, task_yield, task_suspend, task_self