import ballerina/io;
public function main() {
    worker w1 {
        io:println("Hello, World! #m");
    }    worker w2 {
        io:println("Hello, World! #n");
    }    worker w3 {
        io:println("Hello, World! #k");
    }
}

Hello World Parallel

This example uses Ballerina to print “Hello, World!” in parallel using workers. A worker is a sequence of statements that is executed concurrently with all other workers in the function.

import ballerina/io;
public function main() {
    worker w1 {
        io:println("Hello, World! #m");
    }

Use one or more workers to define a function execution. The function invocation starts all the workers.

    worker w2 {
        io:println("Hello, World! #n");
    }
    worker w3 {
        io:println("Hello, World! #k");
    }
}
# To run this sample, navigate to the directory that contains the
# `.bal` file, and execute the `ballerina run` command.
$ ballerina run hello_world_parallel.bal
Hello, World! #m
Hello, World! #k
Hello, World! #n