3.1 meach - Execution method for simple parallel processing

Method of Array class for simple parallel processing without exclusive control. It is a simple implementation to initiate multiple processes asynchronously.

3.1.1 Format

1) Array::meach(mpcount){|value| block}
2) Array::meach(mpcount){|value,count| block}

Process the code in parallel by block when value is given as the block parameter of an element in an array. If count is given as a block parameter, set the array element number (integer from 0) being processed.

mpcount - Number of parallel processes.

3.1.2 Examples

Example 1 Print row number and value from field name

# Process five elements from 10 to 6 (integer) in two parallel threads. 
# Processing content is as simple as displaying the value of element and the element 
number of the array. 
> [10,9,8,7,6].meach(2){|value,count|
>   puts "#{value},#{count}"
> }
10,0
9,1
8,2
7,3
6,4

3.1.3 Related Command