Everybody should write everything in Go. This is how easy concurrent/"threaded" applications are... I passed a string for pedagogical purposes. :) No pthread... not stupid crap... just works! :)


package main

import (
"fmt"
"strconv"
)

func whatever(c chan string, thr int) {
for i := 0; i < 100; i++ {
fmt.Printf("%d\n",i)
}
c <- "Thread "+strconv.Itoa(thr)+" done!"
}

func main() {
c := make(chan string)
for i := 0; i < 4; i++ {
go whatever(c,i)
}
for g := 0; g < 4; g++ {
fmt.Printf("%v\n", <-c)
}
}

Holy f%#9... we live in the future. +The Go Programming Language
Shared publiclyView activity