library(parallel) cl = makeCluster(detectCores()) clusterSetRNGStream(cl) clusterEvalQ(cl, library(MASS)) results = clusterApply(cl, rep(25, 4), function(nstart) kmeans(Boston, 4, nstart=nstart) ) i = sapply(results, function(result) result$tot.withinss) result = results[[which.min(i)]] stopCluster(cl) library(parallel) cl = makeCluster(4, type='PSOCK') res = parLapply(cl, 1:1000000, sqrt) system.time({res = parLapply(cl, 1:1000000, sqrt)}) stopCluster(cl) cl = makeCluster(4, type='FORK') res = parLapply(cl, 1:1000000, sqrt) system.time({res = parLapply(cl, 1:1000000, sqrt)}) stopCluster(cl)