Concurrency
Golang:
package main
import (
"fmt"
"time"
)
func execute(codingninjas string) {
for i := 1; true; i++ {
fmt.Println(codingninjas, i)
time.Sleep(time.Millisecond * 100)
}
}
func main() {
// Simple and concurrent go program
go execute("First Statement ")
execute("Second Statement ")
fmt.Println("program ends successfully")
}
PHP (Vapm):
<?php
declare(ticks=1);
use vennv\vapm\CoroutineGen;
function execute(string $name)
{
for ($i = 0; true; $i++) {
echo "$name $i\n";
yield CoroutineGen::delay(100);
}
}
CoroutineGen::runNonBlocking(
execute("First Statement ")
);
iterator_to_array(execute("Second Statement "));
Last updated