library(rlecuyer) .lec.SetPackageSeed(c(42, 666, 100001, 123454321, 7, 123456789)) nstream <- 4 stream.names <- LETTERS[1:nstream] stream.names .lec.CreateStream(stream.names) ##### .lec.WriteStateFull(stream.names) for (i in 1:nstream) { .lec.CurrentStream(stream.names[i]) .lec.IncreasedPrecis(stream.names[i], incp = TRUE) cat("stream", stream.names[i], "\n") print(runif(5)) .lec.CurrentStreamEnd() } library(multicore) ##### note we don't reset the seed; we just keep using the streams foo <- function(name) { .lec.CurrentStream(name) result <- runif(5) .lec.CurrentStreamEnd() return(result) } for (i in 1:nstream) parallel(foo(stream.names[i]), name = stream.names[i]) out <- collect() out ##### try it again for (i in 1:nstream) parallel(foo(stream.names[i])) out2 <- collect() out2