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. Form a sequence of values returned by the code block and enter them into the fork cell.

 

Use #c to represent parallel thread number in the code block.

Parameter:

Ai

A sequence

Example:

Single parameter:

 

A

B

 

1

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

 

Return the return results of multithreads once the fork code block is executed.

2

 

=connect("demo")

 

3

 

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

EID is the parameter.

4

 

=B2.close()

 

5

 

return B3

 

 

Multiple parameters:

 

A

B

 

1

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

/

Return the return results of multithreads once the fork code block is executed.

2

 

=connect("demo")

 

3

 

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

EID is the first sequence parameter, GENDER is the second sequence parameter.

4

 

=B2.close()

 

5

 

return B3

 

 

Use parallel thread number:

 

A

B

 

1

=file("PersonnelInfo.txt")

 

 

2

fork to(4)

 

3

 

=A1.import@t(;A2:4)

Retrieve records from data file A1 using multiple threads

4

 

return #A2|B3

#A2 represents the parallel thread number.

Related functions:

callx()

call()