fork A i ,…

Description:

Use multithreads to execute the code block in a cellset.

Syntax:

fork  Ai,

Note:

Ai is a sequence parameter, whose length determines the number of parallel threads. The statement makes multiple duplicates of the current cellset and its context to execute them respectively using multiple threads. A sequence parameter will be separated to have its members respectively used as the value of current cell for the execution of each thread; and a single-value parameter will be duplicated to be distributed to each thread. The result of return statement in the code block will be used in the form of a sequence as the cell value of the main program to call the subroutine.

Parameters:

Ai

A sequence

Example:

1)  Single parameter

 

A

B

1

fork [[1,20,6,14,5],[32,8]]

//return the result of executing result statement of multithreads

2

 

=connect("demo")

3

 

=B2.query("select * from EMPLOYEE where EID in (?) ",A1)

4

 

=B2.close()

5

 

return B3

 

2)  Multiple parameters

 

A

B

1

fork [[1,20,6,14,5],[32,8]],"F"

//return the results of executing result statement of multithreads

2

 

=connect("demo")

3

 

=B2.query("select * from EMPLOYEE where EID in (?) and GENDER=?",A1(1),A1(2))

4

 

=B2.close()

5

 

return B3

Related functions:

callx()

call()