'All parallel processes in foreach loop in R generating same results

I use foreach() loop to generate random arrays in parallel. But I am getting same results in all parallel process. How do I add randomness in each parallel process so that each process is different from each other?

library(doFuture)
library(foreach)

# Parallel programming
registerDoFuture()
plan(multicore, workers = 3)


res = foreach(iter = 1:3) %dopar%
{
  
  # generate random array
  x = runif(n = 5)
  
}

All arrays generated in parallel are same

> res
[[1]]
[1] 0.55882648 0.73863525 0.51284839 0.01454722 0.08909375

[[2]]
[1] 0.55882648 0.73863525 0.51284839 0.01454722 0.08909375

[[3]]
[1] 0.55882648 0.73863525 0.51284839 0.01454722 0.08909375


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source