Create - Maple Help

 Create
 evaluate an expression in a new thread

 Calling Sequence Create( expr, opt1, opt2, ... ) Create( expr, var, opt1, opt2, ... )

Parameters

 expr - (anything) the expression to evaluate in the new thread var - (name) (optional) an output variable for the result opt1, opt2, ... - optional arguments

Description

 • The Create command is used to start evaluating a Maple expression in a new thread.  This command returns an integer identifier for the new thread.
 • When the evaluation of expr is finished, the thread terminates.  If var is given, the result of the evaluation is assigned to var.
 • The identifier returned by Create can be passed into Wait.
 • Due to the unique functionality of Create, there are special evaluation rules for expr.  If expr is a procedure, then the arguments to the procedure are evaluated in the current thread, but the function call itself is evaluated in the new thread.  If expr is not a procedure, then it is evaluated entirely in the new thread.
 • One side effect of these rules is that if expr is a function call, with another function call as an argument, the argument will be evaluated in the current thread, not the new thread.
 • There is one optional argument: stacksize
 stacksize = integer

The stacksize optional argument specifies the maximum amount of stack space available to the new thread.  The maximum stack size of a thread is fixed at thread creation time and cannot be changed.  By default the stack size is the minimum allowed stack, which is platform dependent.

Examples

 > with(Threads); p := proc( n )    local j;    global i;        for j from 1 to n    do        i := j;    end do; end proc:
 $\left[{\mathrm{Add}}{,}{\mathrm{ConditionVariable}}{,}{\mathrm{Create}}{,}{\mathrm{Map}}{,}{\mathrm{Mul}}{,}{\mathrm{Mutex}}{,}{\mathrm{Self}}{,}{\mathrm{Seq}}{,}{\mathrm{Sleep}}{,}{\mathrm{Task}}{,}{\mathrm{Wait}}\right]$ (1)
 > $\mathrm{id}≔\mathrm{Create}\left(p\left({10}^{6}\right)\right)$
 ${\mathrm{id}}{≔}{1}$ (2)
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}j\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{10}^{4}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\left(\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$
 > $i$
 ${30468}$ (3)
 > $\mathrm{Wait}\left(\mathrm{id}\right)$
 > $i$
 ${1000000}$ (4)
 > $\mathrm{id}≔\mathrm{Create}\left(\mathrm{int}\left({\mathrm{sin}\left(x\right)}^{x},x\right),d\right)$
 ${\mathrm{id}}{≔}{2}$ (5)
 > $d$
 ${d}$ (6)
 > $\mathrm{Wait}\left(\mathrm{id}\right)$
 > $d$
 ${\int }{{\mathrm{sin}}{}\left({x}\right)}^{{x}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}$ (7)