Our example demonstrates the use of lightweight threads of execution. Here’s the source code translated into OCaml.
To run the program, compile the code and execute it.
First, save the code into a file named example.ml.
Then, run the compiled program:
In this example, the output of the main function call is shown first, followed by the output from the two concurrent threads. Output from the threads may be interleaved, reflecting the concurrent execution.