Difference between revisions of "Loop"

From wikieduonline
Jump to navigation Jump to search
Line 12: Line 12:
 
}
 
}
 
</pre>
 
</pre>
 +
 +
Go do not support parallel for-loops , Sun's [[Fortress]] support it. But they are easy to implement using [[goroutines]].<ref>http://www.golangpatterns.info/concurrency/parallel-for-loop</ref>
  
  
Line 22: Line 24:
 
done
 
done
 
</pre>
 
</pre>
 
  
 
== See also ==
 
== See also ==

Revision as of 06:46, 29 April 2020


Infinite loop

go

sum := 0
for {
    sum++ // repeated forever
    fmt.Println(sum)
}

Go do not support parallel for-loops , Sun's Fortress support it. But they are easy to implement using goroutines.[1]


Bash

#!/bin/bash
while true; do
 ((var++))
echo $var
done

See also

  • http://www.golangpatterns.info/concurrency/parallel-for-loop
  • Advertising: