CONCURRENT-END Statement |
The CONCURRENT statement may be used to perform tasks concurrently in separate threads.
Caution |
---|
Alchemy waits for all statements within the CONCURRENT-END block to complete before execution starts on the following statement |
CONCURRENT [statement1] [statement2] [statement3] END
statementX | A statement block or single statement to be executed concurrently with other statementXs. |
Suppose that a script contained the following code segment to build two large lookup tables:
CREATE LOOKUP areaById ON %area_name FROM "data\area" INDEX BY %id; CREATE LOOKUP cityFromPostcode ON %city FROM "data\cities" INDEX BY %postcode;
If we were to run the code on a dual-CPU machine we could use the CONCURRENT statement to better leverage the capabilities of both CPUs by building the lookup tables in separate threads:
CONCURRENT BEGIN CREATE LOOKUP areaById ON %name FROM "data\area" INDEX BY %id; END BEGIN CREATE LOOKUP postCodes ON %suburb FROM "data\suburbs" INDEX BY %postcode; END END PRINT "Done!";
Note |
---|
Note that the PRINT statement is not executed until both LOOKUP statement blocks have completed and their threads have joined. |