Implementing concurrency in V
Using V, you can write a program that runs functions concurrently using the go
keyword. The go
keyword is a built-in keyword in V. The go
keyword is available anywhere in the program without any explicit import
statements required. In the next section, we will understand the basic syntax of the go
keyword.
The go keyword syntax
You can run any function concurrently using the go
keyword, just by writing the go
keyword followed by the name of the function, as shown here:
go FUNCTION_NAME_1(OPTIONAL_ARGUMENTS)
In the preceding syntax, which demonstrates the usage of the go
keyword in V, all we can see is a simple function named FUNCTION_NAME_1
that is being run concurrently. You do not need to make any special syntactical changes to a function to run it concurrently.
With the approach mentioned in the preceding syntax, the active program spawns a new thread and lets the function run concurrently. If the active program is interested in knowing...