Skip to content

Instantly share code, notes, and snippets.

View russel's full-sized avatar

Russel Winder russel

  • London
View GitHub Profile
@gavinking
gavinking / gist:6918556
Last active December 25, 2015 04:39
Parallel algorithm for π, originally by Russel Winder
import java.util.concurrent {
Callable,
ScheduledThreadPoolExecutor
}
void execute(Integer numberOfTasks) {
value n = 1G; // same number of iterations as Java
value delta = 1.0 / n;
value startTime = process.nanoseconds;
value sliceSize = n / numberOfTasks;