Beginning Ballerina Programming by Anjana Fernando & Lakmal Warusawithana

Beginning Ballerina Programming by Anjana Fernando & Lakmal Warusawithana

Author:Anjana Fernando & Lakmal Warusawithana
Language: eng
Format: epub
ISBN: 9781484251393
Publisher: Apress


Let’s remove the comment from line 4 and line 29 and run the code.$ ballerina run workers_iteration2.bal

Worker execution started

Worker execution finished

w1: sum of first 10000000 positive numbers = 50000005000000

w2: sum of squares of first 10000000 positive numbers = 1291990006563070912

Now you can see that line 4 and line 29 executed and printed before the two workers print the sum of n and the sum of n squares. This is because if explicit workers are not mentioned within worker blocks, the function code will belong to a single unnamed default worker.

If you want to wait for both workers to get printed sums before line 29 gets printed, you can uncomment line 27, ( _ = wait {w1, w2}; ), which makes it wait before it executes.$ ballerina run workers_iteration2.bal

Worker execution started

w1: sum of first 10000000 positive numbers = 50000005000000

w2: sum of squares of first 10000000 positive numbers = 1291990006563070912

Worker execution finished



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.